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.

Listing cases and their details with the Connect SDK on Android

Updated on July 18, 2018

This tutorial demonstrates how to configure and integrate the Connect SDK features with a new Android application that was created in the Android Studio development environment using the Java language. The tutorial also explains how to use the Connect SDK Cases API to obtain a list of cases for a user and also to display the specific case details in the Android app.

The tutorial contains the following sections:

This walkthrough takes approximately 30 minutes to complete.
Note: To preview the code, see the CasesTab and CaseDetailsActivity 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 a list of cases

You can use the Cases API to obtain a list of cases for the Pega Platform application.

  1. 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 ListFragment. You must use a FragmentTabHost class, 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 CasesTab. This subclass is where all the logic that is related to obtaining a list of cases for a Pega Platform application is placed.
  3. Override its onCreateView() callback method so that you create an instance of CasesAdapter class, which holds an array of CaseInfo objects for the application. Notice that within this method you also call update(). This method is defined in the next step.
  4. Create the update() method for the CasesTab class. Make a call to getAll() for the Connect SDK Cases API to obtain a list of cases in the connected Pega Platform instance. Notice that the cases().getAll() Connect SDK method is called on the previously obtained PegaComponent 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. The data for all returned cases is saved by using the setData() method in the instance of the CaseAdapter object.
  5. You can now override the onListItemClick() method that is called when the user clicks one of the case names that is displayed. An instance of the CaseInfo object is created to store the case details. In addition, an instance of the CaseDetailsActivity object is created and started in the Android app. The app advances to the next screen, passing the identifier, name, status, and urgency of the single case that was clicked. The next section describes how to obtain these case details that were passed by using the Connect SDK Cases API and display it on the screen.

Obtaining case details

After you receive a list of cases, you can add the Java code that obtains the details for a particular case based on its identifier.

  1. 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 ListFragment. You must use a FragmentTabHost class, 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 CasesTab. This subclass is where all the logic that is related to obtaining a list of cases for a Pega Platform application is placed.
  3. Override its onCreateView() callback method so that you create an instance of CasesAdapter class, which holds an array of CaseInfo objects for the application. Notice that within this method you also call update(). This method is defined in the next step.
  4. Create the update() method for the CasesTab class. Make a call to getAll() for the Connect SDK Cases API to obtain a list of cases in the connected Pega Platform instance. Notice that the cases().getAll() Connect SDK method is called on the previously obtained PegaComponent 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. The data for all returned cases is saved by using the setData() method in the instance of the CaseAdapter object.
  5. You can now override the onListItemClick() method that is called when the user clicks one of the case names that is displayed. An instance of the CaseInfo object is created to store the case details. In addition, an instance of the CaseDetailsActivity object is created and started in the Android app. The app advances to the next screen, passing the identifier, name, status, and urgency of the single case that was clicked. The next section describes how to obtain these case details that were passed by using the Connect SDK Cases API and display it on the screen.

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