I'm simply trying to launch one of my apps from within another app. I have this code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.my.app","com.my.app.Main"));
startActivity(intent);
But it keeps giving me this error:
Unable to find explicit activity class {com.my.app/com.my.app.Main}; have you declared this activity in your AndroidManifest.xml?
Which manifest is it referring to? The second app that I'm trying to launch, or the app from which I'm trying to launch it? Also, what am I supposed to be declaring exactly?
If you need more information, please let me know. It's probably something simple but I've looked through all the related questions / answers on SO and none of the solutions worked for me.
Thanks!
Use this, the package name can be used to launch the application.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
if (launchIntent != null) {
startActivity(launchIntent);//null pointer check in case package name was not found
}
I hope this helps you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With