美文网首页
Android 打开其他 app

Android 打开其他 app

作者: crianzy | 来源:发表于2016-06-16 15:26 被阅读522次

通过包名获取 启动的 intent (推荐使用)

     public static Intent getMainIntent(Context context, String packageName) {
          return context.getPackageManager().getLaunchIntentForPackage(packageName);
     }
    Intent intent = getMainIntent(getApplicationContext(), "com.zuimeia.suite.lockscreen.international");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(EXTRA_LAYOUT_ID, themeid);
    startActivity(intent);

通过包名和MainActivity 名字来启动:


     Intent intent = new Intent(Intent.ACTION_MAIN);
     intent.addCategory(Intent.CATEGORY_LAUNCHER);         
     ComponentName cn = new ComponentName(packageName, className);         
     intent.setComponent(cn);
     startActivity(intent);

相关文章

网友评论

      本文标题:Android 打开其他 app

      本文链接:https://www.haomeiwen.com/subject/ojvmdttx.html