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 case types and creating cases 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 environment by using Java. The tutorial explains how to use the Connect SDK Casetypes API to obtain a list of case types and also how to create a case.

The tutorial contains the following sections:

This walkthrough takes approximately 25 minutes to complete.
To preview the code, see the CaseTypesTab and CaseCreationActivity 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 case types

You can use the Casetypes API to obtain a list of case types for the authenticated user.

  1. In the Android Studio environment, right-click the package where the new class is to be created, and click New > Java Class.
  2. 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.
  3. Name the class CaseTypesTab. This class is where all the logic that is related to obtaining case types for the Pega Platform application is placed.
  4. Override its onCreateView() callback method so that you create an instance of the CaseTypeAdapter class, which holds an array of CaseType objects for the application. Notice that within this method you also call update(). This method is defined in the next step.
  5. Create the update() method for the CaseTypesTab class. Make a call to getAll() for the Connect SDK Casetypes API to obtain a list of case types in the connected Pega Platform instance. Notice that the caseTypes().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 case types is saved by using the setData() method in the instance of the CaseTypesAdapter object.
    Case type list - CaseTypes API
    Case type list - Casetypes API
  6. You can now override the onListItemClick() method that is called when the user taps one of the case type names that are displayed. An instance of the CaseType object is created to store the tapped case type. In addition, an instance of the CaseCreationActivity object is created and started in the Android app. The app advances to the next screen, passing it the identifier of case type that was tapped. The next section describes how to create a case of the case type that was tapped.

Creating a case

The code developed in this section demonstrates how to create a case in your Android application by using the Casetypes API of the Connect SDK.

  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 Activity. Name the subclass CaseCreationActivity. This class is where all the logic that is related to creating a new class of a selected type is placed.
  2. Override the onCreate() callback method, which is called when an instance of this class is called. Within this method, obtain the case type ID that was previously tapped by the user so that it can be used to create a new case in step 4.
  3. Create a reference to the Create Case button in the onCreate() listener method.
    Button createCase = (Button) findViewById(R.id.createCase);
  4. Create an anonymous instance of the View.OnClickListener() class and, inside its overridden onClick() method, add Java code that allows the user to create a case of the current case type in the Android app when the Create Case button is clicked.

    The cases().createCase() 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. Note that you pass the current case type ID to the createCase() method, as its first parameter. The parent case ID is not used, so it is set to a null value, and finally, for the content we use the data that was entered in the key and value fields on the screen, respectively. The createCase() method's onSuccess() and onFailure() callbacks let you define what to do when a new case is successfully created or not.

    Create case - Case API
    Create case - Case API

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