Portal Organizational Info Sample
The purpose of this sample is to show how to create a portal, and thereby use portal info to get information about the organization. This is equivalent to a hello world sample for the portal.
Sample Design
This sample has a layout to which information obtained from the portal info object is displayed.
All the calls to the portal are executed in an Async task, in the doInBackground(…) method. The async task is executed by creating a private class that extends from the AsyncTask class. The execute method on the async task starts the execution.
The portal is created using the constructor which takes credentials and portal url. 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. In order to display the text information in the layout views, use the UI thread in the activity and display the information. The portalInfo also has the thumbnail used for a organization and portal. The thumbnail must be fetched using the PortalListener with byte[] parameter. On the portalInfo object, use the fetchOrg/PortalThumbnail method, pass it the PortalListner<byte[]>. When the callback returns with the byte array, convert the byte array to a bitmap and display it in the imageview defined in the layout. Since the callback listener thread is separate from the activity ui thread, spawn a ui thread from the main activity and add the bitmap to the imageview.
For convenience a progress bar has been added, it stops spinning when the callback from the thumbnail is completed.
Using the Sample
- Install the APK on your device
- The sample launches the progress bar
- When the task is completed, the progress dialog goes away and the UI is populated with the information from the Portal.