Reputation: 12616
I'd like to use activities that are not bundled with my app. How could I do that? Using intents or something? I am sure it must be simple.
The main problem is that I can't actually do this:
new Intent(this, SomeExternalActivity.class))
because I can't import the class (it's an external app). Something similar, using a string or something.
Thanks a lot!
This one doesn't work either:
new Intent(this, Class.forName("com.somepackage.SomeExternalActivity");
Upvotes: 0
Views: 285
Reputation: 24464
The activity you are calling should appear not only in the Manifest for its own package, but in the Manifest for the CALLING package, too.
Upvotes: 1
Reputation: 6447
This is a working example, for the RemoteDroid
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.joshsera", "com.joshsera.RemoteDroid");
startActivity(intent);
Upvotes: 1
Reputation: 4091
You can only start activities bundled with your app with this constructor:
Intent(Context packageContext, Class<?> cls)
You will need to use one of the following to access an external activity:
Intent(String action)
Intent(String action, Uri uri)
In your case you would use this intent:
new Intent("com.somepackage.SomeExternalActivity");
Also note that to access an activity in another app, that app needs to give access to it's activity (through AndroidManifest.xml)
Check the following for more explanation: http://developer.android.com/reference/android/content/Intent.html http://developer.android.com/guide/topics/manifest/manifest-intro.html http://developer.android.com/guide/topics/intents/intents-filters.html
Upvotes: 1