From one of my apps, I\'m trying to launch another. I want to use an explicit intent.
ComponentName cn = new ComponentName(\"com.myOtherApp\", \"OtherAppActi
As of API23, you could use the method ComponentName.createRelative(String pkg, String cls) and do:
ComponentName cn = new ComponentName(ComponentName.createRelative("com.myOtherApp", ".OtherAppActivity"));
Intent intent = new Intent();
intent.setComponent(cn);
context.startActivity(intent);
This way you can create a ComponentName object using a relative class path. Mind the dot in the start of the class path. It is necessary to indicate that the method should treat the second argument as a relative path. Just as @Sogger mentioned, the ComponentName constructor constraints the class parameter to be an absolute path.
Note also that by this manner, you are using explicit intents and you don't have to insert any additional intent filters to the destination activity.