Portal Feature User Groups Sample

Complexity: Beginner Data Requirement: ArcGIS Tutorial Data for Desktop

The purpose of this sample is to show how to create a portal, get groups from the portal. From each group get the items. Using the item construct a webmap and add it to the mapview.

Sample Design

The sample consists of three activity classes. The FeaturedGroupsList fetches the groups from the portal, when a group is chosen in the listview it passes the groupid via the intent to the ItemListGeneralList. This class fetches the item for the group chosen by the user. When the user chooses an item in the ItemListGeneralList class, the MapActivity is called which is used to display the webmap in the mapview.

In the FeaturedGroupList class the portal is created using the constructor which takes credentials, portal url, and portal listener with Portal. When the portal is created successfully the callback returns with a portal object. If the callback is unsuccessful the error message is thrown.

Once the callback returns, the portalInfo object can be obtained from the portal object using getPortalInfo() method. From the portalInfo.getFeaturedGroupsQueries, returns a list of queries.

At this point the group for each of query will be fetched from the portal. Each time the callback returns the listview adapter is updated. Once a group is selected the next activity is launched where the items for that group are fetched from the portal and displayed in the listview.

Once an item is chosen from the item list, a webmap is constructed. This is done in the mapviewactivity. The webmap is created using the item chosen in the item list, when the callback returns successfully the webmap is added to the mapview. In order to add the webmap a uithread must be used from the main activity.

As a general observation since the callback runs in a thread separate from the ui thread of the activity, in order to add any of the data from the portal to a ui element, the user must start a ui thread in the activity that is currently being used.

For convenience a progress dialog has been added, it stops spinning when the callbacks in the various activities are completed.

Using the Sample

Steps:
  1. Install the APK on your device
  2. The sample launches the progress dialog
  3. When the task is completed, the progress dialog goes away
  4. Select a group displayed in the list view
  5. Select an item displayed in the list view
  6. The corresponding map will be displayed on your device
5/31/2012