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.

Obtaining data page contents and metadata with the Connect SDK on Android

Updated on July 18, 2018

This tutorial demonstrates how to configure and integrate Connect SDK features with a new Android application created in the Android Studio development environment by using Java language. Its purpose is to show how to use the Connect SDK Data API to obtain the contents of a data page and also to obtain the metadata for a specific data page.

This walkthrough takes approximately 20 minutes to complete.
To preview the code, see the DataPageTab and DataPageActivity demo application classes that are part of the com.pega.helloconnectsdk package.

Prerequisites

Before you start this tutorial, do the following tasks:

  • Read Creating a Hello World Android app with the Connect SDK, which describes how to set up the Connect SDK in the Android Studio environment, initialize it, and use it to authenticate.
  • Download ConnectSDKDemo.zip which contains the sample Java code and other Android Studio project files for the Android app described in this tutorial.

You can connect to any Pega® Platform instance to test the Android app. Make sure that it already includes some cases and assignments.

Obtaining data page contents

To add logic that allows your native Android app to obtain the data page contents from a Pega instance, you must call the getDataPage() method for the already initialized Connect SDK and pass it the name of the data page. The two Java classes created in this section are reused to also obtain the data page metadata, as explained in the next section.

  1. In the Android Studio environment, right-click the package where the new class is to be created, and click New > Java Class. Proceed to create a subclass of Fragment . You must use a special TabHost that allows the use of Fragment objects for its tab content. For more information, consult the TabsActivity.java file for the included sample project and the Android developer guide.
  2. Name the class DataPageTab. This subclass is where all the logic that is related to obtaining the data page contents for a Pega Platform application is placed. It is also used to obtain the metadata page contents. This is explained in the next section.
  3. Override its onCreateView() callback method so that it includes a reference to the Get Datapage button inside it.
  4. Within the method, create an anonymous instance of the View.OnClickListener() class and, inside of its overriden onClick() method, add Java code that advances to the next screen. To do so, an instance of the DataPageActivity object is created and started in the Android app, passing it the name of the data page for which to display the contents. This object is created in the next step.
  5. In the Android Studio environment, right-click the package where the new class is to be created, and click New > Java Class. Create a subclass of Activity. Name the subclass DataPageActivity. This class is where all the logic that is related to displaying data page and metadata contents is placed.
  6. Override the onCreate() callback method, which is called when an instance of this new class is called.
  7. Obtain the data page name that was passed to this class and use it to obtain its contents. Notice that within the else if() statement, the data().getDataPage() Connect SDK method is called on the previously obtained Pega object. You obtain this object by first getting an instance of the PegaSingleton object by using the getInstance() method, and then calling the getPega() method on it. Notice that you pass the current name of the data page to the getDataPage() method as its first parameter. If the data page content was successfully obtained, within the onSuccess() callback you display it on the screen. Otherwise, if an error occurred, within the onFailure() callback you log an error message.
    Data Page API
    Get data/Get metadata - Data Page API

Obtaining data page metadata

To get the metadata of a data page in your Pega Platform application, you must call the getDataPageMetadata() method for the already initialized Connect SDK by passing it the name of the data page. The DataPageTab and DataPageActivity classes created in the previous section is used to add this functionality.

  1. In the DataPageTab.java file, edit the contents within the onCreateView() callback method so that it also includes a reference to the Get Metadatapage button inside it.
  2. Within this callback method, create an anonymous instance of the View.OnClickListener() class and, inside of its overriden onClick() method, add Java code that advances to the next screen. To do so, an instance of the DataPageActivity object is created and started in the Android app, passing it the name of the data page for which to display the metadata.
  3. In the DataPageActivity.java file, add the code within the if() statement that obtains the metadata content for the passed data page. This is where the data().getDataPageMetadata() Connect SDK method is called on the previously obtained Pega object. You obtain this object by first getting an instance of the PegaSingleton object by using the getInstance() method, and then calling the getPega() method on it. Notice that you pass the data page name as its first parameter. If the metadata was successfully obtained, within the onSuccess() callback you display it on the screen. Otherwise, if an error occurred, within the onFailure() callback you log an error message.

Related articles

Advanced mobile featuresConnect SDKCreating a Hello World Android app with the Connect SDKListing cases and their details with the Connect SDK on AndroidListing case types and creating cases with the Connect SDK on AndroidListing assignments and their details with the Connect SDK on Android

Tags

Pega Platform 7.3.1 Pega Mobile Mashup Mobile Pega Express Communications and Media Consumer Services Financial Services Government Healthcare and Life Sciences Insurance Healthcare and Life Sciences Manufacturing Consumer Services

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.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us