简体   繁体   中英

Is it possible to start an activity in a different apk using startActivity on Android using the activity name or similar?

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?

Yes.

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

new Intent("com.google.android.gm", "com.google.android.gm.ConversationListActivity");

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 ?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM