1

Hello i wan't to keep home activity name for launch it from my app.

I know we can launch the launcher without know is package name but. I'm making a custom home and i will set it as default so this will launch my custom home.

I wan't to keep the launcher activity name on a shared preference the first time i launch my custom home and then i will be able to go on the default home from my personal home(without delete my home preference i will keep it as default and launch default home just for some debug test)

Don't know if i'm clear; i have difficult to understood myself in this subject so for resume I need at the first launch of my activity get the name of the default launcher(because it's not com.android.launcher for every device) and keep it to be able to launch it after some time

Any idea?

4

2 回答 2

2

Finaly i don't keep the name i don't care of it i just use the following code to launch a launcher who is not mine :P

PackageManager pm = getPackageManager();
Intent i = new Intent("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
List<ResolveInfo> lst = pm.queryIntentActivities(i, 0);
if (lst != null) 
{
  for (ResolveInfo resolveInfo : lst) {
    if (resolveInfo.activityInfo.packageName != getPackageName()){
      Intent res = new Intent();
      String mPackage = resolveInfo.activityInfo.packageName;
      String mClass = resolveInfo.activityInfo.name;
      res.setComponent(new ComponentName(mPackage,mClass));
      startActivity(res);
    }
  }
}
于 2013-05-22T07:24:42.747 回答
0

you can get application registered with intent action android.intent.category.HOME, and you can get package list for aplication registered with this intent. May be this can also help

于 2013-05-14T08:49:34.263 回答