Links may not function; however, this content may be relevant to outdated versions of the product.
Create a case with the Mashup SDK for Android
You can use the Mashup SDK in a native Android app to display an embedded Pega® Platform application in a hybrid web view. The Mashup SDK allows a user to create a case, open an existing case, show a harness, open an assignment, or run an activity in a mobile environment. For example, if a native Android app is used as a custom service application to provide road assistance for customers, a user can create a case in an external hybrid web view to report car trouble.
- Prerequisites
- Authenticate to a Pega Platform application
- Create a case in a hybrid web view
- Hide the hybrid web view
Prerequisites
Before you continue, make sure that you have set up the Mashup SDK for Android app development. Make sure that you also have access to the Mashup SDK Javadoc documentation that is included with the Pega Mashup SDK distribution package.
Authenticate to a Pega Platform application
Before you create a case in a Pega Platform application, you must authenticate with it. Use the SnapStart
object's login()
method to log in to a Pega Platform instance. By calling this method, you obtain an instance of the SnapStart
object that is later used to create a case. Various signatures of this method are available in the Mashup SDK. For more information, see the Mashup SDK Javadoc documentation for the SnapStart
object.
The static asynchronous login()
method for the SnapStart
object takes the following parameters:
- The
SnapStart.LoginListener
object. - URL address (string type) of the Pega Platform server that you want to connect to. Specify the URL address in the following format:
http://<SERVER_NAME>:<PORT>/prweb/
- The user name (string type) used to log in to the Pega Platform application.
- The password (string type) used to log in to the Pega Platform application.
The following Java code demonstrates how to call the static asynchronous static login()
method. You obtain an instance of the SnapStart
object in the onSuccess()
method for the SnapStart.LoginListener
object. This code is used to create a case in an embedded screen of a Pega Platform application as a hybrid web view.
SnapStart.login( new MySnapStartLoginListener(), "http://test.pega.com:80/prweb", "jdoe", "secret"); class MySnapStartLoginListener extends SnapStart.LoginListener { @Override public void onStart() { // do any actions prior to logging in }; @Override public onSuccess(SnapStart snapStart) { // perform actions once successfully logged in // using the reference to the instantiated // SnapStart object }; @Override public onFailure(SnapStartLoginException cause) { // handle errors that occurred during logging in }; };
Create a case in a hybrid web view
Use the SnapStart
Mashup SDK object's createCase()
method to create a case in an embedded Pega Platform application screen as a hybrid web view. Various signatures of this method are available in the Mashup SDK. The createCase()
method is invoked in a hybrid web view and takes the following parameters:
- The
SnapStart.WebViewActionListener
object. - The
HybridWebView
object represents the hybrid web view to open in the native Android app. - className (string type) defines the class name of the case.
- flowName (string type) defines the name of the case flow to run.
The following Java code demonstrates how to create a case as a hybrid web view of an embedded Pega Platform application screen.
snapStart.createCase( new MySnapStartWebViewActionListener(), hybridWebView, "Wb-CarIssue-Case", "pyStartCase" ); class MySnapStartWebViewActionListener extends SnapStart.WebViewActionListener { @Override public void onComplete() { // perform actions once creating a case was successful } @Override public void onFailure(SnapStartError error) { // handle errors that occurred during creating a case } @Override public void onStart() { // perform any additional actions like displaying // a progress bar before displaying the creating // a case hybrid web view } @Override public void onQuit() { // perform any actions once completing the case // for example, hiding the hybrid web view } };
Hide the hybrid web view
When a user creates a case, for example, by submitting details about car trouble, you must hide the embedded Pega Platform hybrid web view in the native app. Add the following code in the onQuit()
method for the SnapStart.WebViewActionListener
object. This method runs when the user submits the case in the embedded hybrid web view. For more information, see the Mashup SDK Javadoc documentation for the SnapStart.WebViewActionListener
object.
@Override public void onQuit() { hybridWebView.setVisibility(View.GONE); };