Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The users must first install the app catalog application on the device from the App store:  https://<EMM_HOST>:<EMM_PORT>/store/  

  • Once the app catalog is installed on the device it will directly call the services exposed by the WSO2 EMM Agent. The EMM agent will fetch the details of all the available applications, install or uninstall applications based on the request made by the app catalog. 

    Info

    The diagram given below will help you understand how the app catalog works in WSO2 EMM.

  • After successfully installing the app catalog, you will access it to install / install applications or get the list of available applications. At that point it will automatically navigate to the WSO2 EMM agent's screen to list out all the available applications.

...

API for the application download status

The Android app catalog application provides an API for external applications to know the application download progress. To invoke this API, the external applications need to invoke the service exposed by the app catalog application and implement a BroadcastReceiver to receive results. 


Service name to be used when invoking : org.wso2.app.catalog.START_SERVICE

Action name to call API to receive a result : org.wso2.app.catalog.MESSAGE_PROCESSED

Operation code to be used when invoking : APP_DOWNLOAD_PROGRESS


Result intent parameters :

status : 200(success) or 400(failure).

payload : Result payload.


Service will return a JSON output as the payload

{

  “app” : “APPLICATION PACKAGE NAME”,

  “progress” “DOWNLOAD PROGRESS”

}


 

Given below is how to invoke the API by starting the service exposed.

Code Block
languagejava
titleSample BroadcastReceiver
firstline1
linenumberstrue
public class CatalogServiceResponseReceiver extends BroadcastReceiver {
   @Override
   public void onReceive(Context context, Intent intent) {
         String status = intent.getStringExtra(“status”);
         JSONObject result = new JSONObject(intent.getStringExtra(“payload”));
         //Your result manipulation code goes here
   }
}


Code Block
languagejava
titleRegistering a receiver to listen to service results
firstline1
linenumberstrue
Context context = getApplicationContext();
IntentFilter filter = new IntentFilter(“org.wso2.app.catalog.MESSAGE_PROCESSED”);
filter.addCategory(Intent.CATEGORY_DEFAULT);
CatalogServiceResponseReceiver receiver = new CatalogServiceResponseReceiver();
registerReceiver(receiver, filter);

 

 

Code Block
languagejava
titleCalling the service (This should happen ALWAYS after registering the receiver)
firstline1
linenumberstrue
Intent intent =  new Intent(“org.wso2.app.catalog.START_SERVICE”);
Intent explicitIntent = createExplicitFromImplicitIntent(context, intent);
if (explicitIntent != null) {
  intent = explicitIntent;
}
intent.putExtra("code", “APP_DOWNLOAD_PROGRESS”);
Code Block
languagejava
titleMethod to create an explicit intent
firstline1
linenumberstrue
public static Intent createExplicitFromImplicitIntent(Context context, Intent implicitIntent) {
  //Retrieve all services that can match the given intent
  PackageManager pm = context.getPackageManager();
  List<ResolveInfo> resolveInfo = pm.queryIntentServices(implicitIntent, 0);

  //Make sure only one match was found
  if (resolveInfo == null || resolveInfo.size() != 1) {
     return null;
  }

  //Get component info and create ComponentName
  ResolveInfo serviceInfo = resolveInfo.get(0);
  String packageName = serviceInfo.serviceInfo.packageName;
  String className = serviceInfo.serviceInfo.name;
  ComponentName component = new ComponentName(packageName, className);

  //Create a new intent. Use the old one for extras and such reuse
  Intent explicitIntent = new Intent(implicitIntent);

  //Set the component to be explicit
  explicitIntent.setComponent(component);

  return explicitIntent;
}