0

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!

Alex Zaitsev
  • 2,013
  • 4
  • 30
  • 56

2 Answers2

2

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

Regards

Ziteng Chen

Ziteng Chen
  • 1,959
  • 13
  • 13
1

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.

Marek R
  • 32,568
  • 6
  • 55
  • 140