Portal Feature User Groups Sample
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
- Install the APK on your device
- The sample launches the progress dialog
- When the task is completed, the progress dialog goes away
- Select a group displayed in the list view
- Select an item displayed in the list view
- The corresponding map will be displayed on your device