How to start ApiDemos in Android App
I am trying to start the ApiDemos application inside of my Application using an intent. I created the following intent:
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);
When my code calls this intent it catches a SecurityException
and gives the following detailed message: Requesting code from com.example.android.apis (with uid 10035) to be run in process com.TICE.customtabs (with uid 10036)
Is there any way for me to call ApiDemos a开发者_如何学JAVApp from within my own application? Will I have to just import all of the ApiDemo code and compile it into my app instead?
You don't need category LAUNCHER. This is enough:
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName("com.example.android.apis", "com.example.android.apis.ApiDemos");
startActivity(i);
精彩评论