How to make an Android app that depends on another app?

By : Ande

If I create an app that depends on another app or apps (eg: the Facebook and Twitter apps), yet they are not installed, is there a method of checking for those dependencies and installing them at the same time as my own app?

By : Ande


Here's what I use to return the first mission activity that exists:

                try {
                Class<?> missionClass = Class.forName(mPackageName+".Mission"+mission);
                        Method missionDescription;
                        missionDescription = missionClass.getMethod("missionDescription");
                        mMissionDescription = (String) missionDescription.invoke(null);
                        if (mMissionDescription.length() > 0) {
                            nextMission = mission;
                    } catch (Exception e) {
                        //DEBUG*/Log.v(this.getClass().getName(), "onResume: Mission no "+mission+" not found: "+e.getMessage());

Each mission is held in a separate class, derived from a Mission base class. Derived classes are called Mission1, Mission24 etc.

Not all missions are defined.

The base class has an abstract class missionDescription which returns a string describing the mission.

This code is inside a loop so tests mission=1 to 99, trying to call missionDescription. It returns when the Description for the first mission found is returned.

I think following the pattern outlined in this post on the Android Developer Blog will help you. As TerryProbert points out if you know that the Intent is not available prompt the user to install the missing app.

Start from this:

Intent mediaIntent = new Intent("com.example.intent.action.NAME");
// add needed categories
List<ResolveInfo> listResolveInfo = getPackageManager().queryIntentServices(mediaIntent, 0);
if (listResolveInfo.size() != 0) {
  //normal behavior
} else {
  //install what you need

I give you example of querying services. If you want to check activities, then you will call queryIntentActivities().

By : QuickNick

This video can help you solving your question :)
By: admin