我正在尝试使用intent在我的Application中启动ApiDemos应用程序。 我创建了以下意图:
Intent i = new Intent();
i.setAction("android.intent.action.MAIN");
i.addCategory("android.intent.category.LAUNCHER");
i.setComponent(ComponentName.unflattenFromString("com.example.android.apis/com.example.android.apis.ApiDemos"));
i.addCategory(Intent.CATEGORY_LAUNCHER);
当我的代码调用此intent时,它会捕获SecurityException
并提供以下详细消息:请求com.example.android.apis(使用uid 10035)中的代码在进程com.TICE.customtabs中运行(与uid 10036)
我有什么方法可以在我自己的应用程序中调用ApiDemos应用程序吗? 我是否必须导入所有ApiDemo代码并将其编译到我的应用程序中?
答案 0 :(得分:0)
您不需要类别LAUNCHER。这就足够了:
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName("com.example.android.apis", "com.example.android.apis.ApiDemos");
startActivity(i);