Skip to content Skip to sidebar Skip to footer

How To Start An Intent From A Resolveinfo

I'm trying to make a custom launcher for android, and I'm trying to figure out how to launch a different application form mine. I figured the way to do it was intents, and I've fo

Solution 1:

Given a ResolveInfo named launchable:

ActivityInfo activity=launchable.activityInfo;
ComponentName name=newComponentName(activity.applicationInfo.packageName,
                                     activity.name);
Intent i=newIntent(Intent.ACTION_MAIN);

i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);

startActivity(i);

(from https://github.com/commonsguy/cw-omnibus/tree/master/Introspection/Launchalot)

Solution 2:

Create an new Intent by this way.

Intentintent=newIntent();
    intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName,
            resolveInfo.activityInfo.name);
    startActivity(intent);

Post a Comment for "How To Start An Intent From A Resolveinfo"