Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Customize a native Android app with the Mashup SDK

Updated on July 25, 2018

When you implement the Mashup SDK for Android in your native mobile app, you can use several advanced features to customize your native mobile app. For example, you can display a temporary screen before a Pega® Platform hybrid web view is loaded on to the app. You can also change the default error log level, use custom authentication, or pass custom parameters.


Before you continue, make sure you have set up the Mashup SDK for Android app development. In addition, make sure that you know how to do the following tasks:

Make sure that you also have access to the Mashup SDK Javadoc documentation that is included with the Pega Mashup SDK distribution package.

Change hybrid web view settings

You can use several methods for the ContainerSettings object to change the default settings for the hybrid web view. For more information, see the Mashup SDK Javadoc documentation for the ContainerSettings object.

For example, the following code demonstrates how to set the error debug level to DEBUG, log errors and warnings to a file, and set the connection time-out period to 90 seconds. Notice that the ContainerSettings object methods are called inside the init() method for the MainActivity class when this object is initialized.

public class MainActivity extends ContainerMyActivity {  
  public void init() {  

Implement screen preloading

When you call one of the Pega Platform actions by using the Mashup SDK, for example, to create a case, it might take a few seconds before the hybrid web view is shown on the screen where a user creates a case. You can add code in the onStart() callback for the WebViewActionListener object to display a temporary screen or a progress dialog box instead of a blank screen before the hybrid web view is displayed. This code is called before Pega Platform action execution.

For example, the following Java code demonstrates how to display a temporary progress dialog box before the hybrid web view is displayed.

private class CreateCaseListener extends SnapStart.WebViewActionListener {  
  private Dialog progressDialog;  
  public void onStart() {  
    // called before action execution  
    progressDialog =,  
  public void onComplete() {  

The following Java code demonstrates how to use the LoadingScreenHandler object to display a temporary screen to the user before the hybrid web view is displayed. For more information, see the Mashup SDK Javadoc documentation for the LoadingScreenHandler object.

// construct LoadingScreenHandler that presents given fragment on top of activity's content  
LoadingScreenHandler loadingScreenHandler = LoadingScreenHandler.create(ScreenPreloadingActivity.this, R.layout.fragment_loading);  
// pass LoadingScreenHandler to WebViewActionListener that displays loading screen while SnapStart action  
// result is loaded into HybridWebView  
WebViewActionListener webViewActionListener = new WebViewActionListener(loadingScreenHandler);  
// execute create case action within HybridWebview  
snapStart.createCase(webViewActionListener, hybridWebView, "className", "pyStartCase");  

Use custom parameters

The Mashup SDK for Android allows you to pass the following types of parameters in the function calls to Pega Platform actions such as creating a case, opening a harness, or running an activity.

The following Java code shows how to pass custom parameters by using the Mashup SDK. For more information, see the Mashup SDK Javadoc documentation for the SnapStartAction object.

String className = "className";  
String flowName = "pyStartCase";  
boolean pyPhoneNavRuleMainVisible = false;  
boolean pyPhoneNavRuleToolbarVisible = false;  
// create optional parameter that will be passed to requested Pega rule  
SnapStartRuleParameter ruleParameter1 = new SnapStartRuleParameter("myCaseParam1", true);  
SnapStartRuleParameter ruleParameter2 = new SnapStartRuleParameter("myCaseParam2", "value");  
// Use Builder for proper SnapStart action - Create case in this example:  
SnapStartAction.Builder action = new CreateCaseAction.Builder()  
   .addRuleParameters(ruleParameter1, ruleParameter2);   
SnapStart.ActionListener actionListener = new SnapStart.ActionListener() {  
  // override ActionListener methods to handle Action result  
snapStart.executeAction(actionListener, action);

Implement custom authentication

If you plan to authenticate to the Pega Platform instance in a custom way, for example, for each login request you require an additional header or a parameter, you must use your own implementation of the ISnapStartAuthenticator object to call the login() method. For more information, see the Mashup SDK Javadoc documentation for the ISnapStartAuthenticator object.

This interface object includes the following methods:

  • getHttpHeaders() – The returned headers are added to every SnapStart HTTP request.
  • getHttpPostParameters() – The returned parameters are added to every SnapStart action.
  • login() – Authenticates to a Pega Platform application.
  • logout() – Signs out from a Pega Platform application.
class MySnapStartAuthenticator implements ISnapStartAuthenticator {  
   public String login() throws SnapStartLoginException {  
    // used to log in using username/password and   
    // Pega Platform instance url.  
  public PegaAuthenticatorResult logout() {  
  public Map<String, String> getHttpHeaders() {  
    Map<String, String> headers = new HashMap<>();  
    headers.put("RequiredHeader", "ItsValue");  
    return headers;  
    // the defined headers will be added to each   
    // query of the SnapStart object instance  
  public List<SnapStartActionParameter> getHttpPostParameters() {  
    List<SnapStartActionParameter> params = new ArrayList<>();  
    params.add(new SnapStartActionParameter("RequiredParam", "ItsValue"));  
    return params;  
    // the defined parameters will be added to each  
    // query of the SnapStart object instance  
SnapStart mySnapStart;  
try {  
  mySnapStart = SnapStart.login(new MySnapStartAuthenticator(  
  /* add any arguments necessary to login here */));  
} catch(SnapStartLoginException e){  
  // handle error  

Related articles

Predefined action parameters for the Mashup SDK for Android


Pega Platform 7.3.1 Pega Mobile Mashup Mobile Pega Express

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us