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 assignments 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 native Android application that was created in the Android Studio development environment by using Java. The tutorial shows how to use the Connect SDK Assignment API to obtain a list of assignments for a user and the details for a specific assignment.

This walkthrough takes approximately 25 minutes to complete.
To preview the code, see the AssignmentsTab and AssignmentDetailsActivity 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 that is 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 assignments

You can use the Assignment API to obtain a list of assignments for a 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 AssignmentsTab. This class is where all the logic that is related to obtaining a list of assignments for the Pega Platform application is placed.

  4. Override its onCreateView() callback method so that you can create an instance of the AssignmentsAdapter class, which holds AssignmentInfo objects for the application. Note that within this method you can also call update(). The contents within this method are defined in the next step.

  5. Create the update() method for the AssignmentTab class. Make a call to getAll() for the Connect SDK Assignment API to obtain a list of assignments in the connected Pega Platform instance. Note that the assignments().getAll() Connect SDK method is called on the previously obtained PegaComponent object. You obtain this by first getting an instance of the PegaSingleton object by using the getInstance() method, and then calling the getPega() method on it. Notice that if successful, within the onSuccess() callback, the data with all returned lists of assignments is saved using the setData() method in the instance of the AssignmentsAdapter object. Within the onFailure() callback, you display an error message when obtaining a list of assignments was not successful.

    List of assignments - Assignment API
    List of assignments - Assignment API
  6. You can now override the onListItemClick() method that is called when the user taps one of the assignments that are displayed. An instance of the AssignmentInfo object is created to store the tapped assignment. In addition, an instance of the AssignmentDetailsActivity object is created and started in the Android app. The app advances to the next screen, passing it the identifier of the assignment that was tapped on the screen. The next section describes how to display details for an assignment.

Obtaining assignment details

The Assignment API also provides the ability to obtain the details of an assignment after you obtain a list of assignments. You can use the identifier for an assignment to display its details. The following steps explain how to use the Connect SDK in your code for this purpose.

  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 Activity. Name the subclass AssignmentDetailActivity. This class is where all the logic that is related to the display of assignment details is placed.

  3. Override the onCreate() callback method, which is called when an instance of this class is called. Within this method, obtain the identifier of the assignment that was previously tapped by the user so that it can be used to display its details.

  4. Make a call to assignments().getAssignment() Connect SDK Assignment API on the previously obtained PegaComponent object, passing it the current assignment to obtain its details. 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. If successful in obtaining assignment details, within the onSuccess() callback you display this information on the screen. If an error occurred, within the onFailure() callback you display an error message.

    Assignment details - Assignment API
    Assignment details - Assignment 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