views:

289

answers:

3

I have tried to write an Android application with an activity that should be launched from a different application. It is not a content provider, just an app with a gui that should not be listed among the installed applications. I have tried the code examples here and it seems to be quite easy to launch existing providers and so on, but I fail to figure out how to just write a "hidden" app and launch it from a different one.

The basic use case is:

  • App A is a normal apk launchable from the application list.
  • App B is a different apk with known package and activity names, but is is not visible or launchable from the application list.
  • App A launches app B using the package and class names (or perhaps a URI constructed from these?).

I fail in the third step. Is it possible to do this?

+1  A: 

Why do you want to use "package and class names" to launch the Activities in the second .apk?

Why not use an Intent since this is the standard way to launch an Activity?

Dave Webb
He is talking about using an Intent, just not using the new Intent(context, Class<?>) constructor.
alexanderblom
+2  A: 

Yes.

Use the package name and class name, like this (for starting Gmail):

new Intent("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
alexanderblom
Yes, this was it. I tried the setClassName(String packageName, String className) method earlier but missed that the class name needed to have the full path so I thought that I had misinterpreted the use of it. Thanks.
icecream
+1  A: 

On the same lines, if I have an application that typically starts an activity, can I build it into an apk by signing it with a private key. Will this allow access to that activity from other apks build by other developers?

Chris