简体   繁体   中英

Android permission denial

I try to launch third-party app from my main activity:

intent = new Intent();

final ComponentName cn = new ComponentName("com.mojang.minecraftpe", 
"com.mojang.minecraftpe.MainMenuOptionsActivity");
intent.setComponent(cn);
intent.setAction(Intent.ACTION_MAIN);
startActivity(intent);

But I get error:

E/AndroidRuntime(22330): java.lang.SecurityException: Permission     Denial: starting  
Intent { act=android.intent.action.MAINcmp=com.mojang.minecraftpe/.MainMenuOptionsActivity
} from ProcessRecord{407b6928 22330:com.metalex.musicplayer/10073} (pid=22330, uid=10073) 
requires null

Please, help me!

The rootcause is that the target activity is not exported, so there is no way to launch it from other apps.

Regards

Ziteng Chen

try this:

Intent intent= getPackageManager().getLaunchIntentForPackage("com.mojang.minecraftpe");
startActivity(intent);

This way you don't have to figure out which activity you can launch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM