Reputation: 19
So I have 2 apps. Let's say I'm in app A, and I know that there is app B and that it is using library C. Library C has an activity that i want to launch from app A. How can I do that?
EDIT: Actually, both A and B apps are using the same library. But my goal is to launch an activity of the another app.
Upvotes: 0
Views: 102
Reputation: 5362
Try this code in Kotlin:
fun runDifferentActivity() {
// Different app package
val otherAppPackage = "comp.package.android.something.there"
// Activity name (from different App)
val otherAppActivity = "SecretActivity"
val action = "$otherAppPackage.$otherAppActivity"
// Create Intent with action name
val intent = Intent(action)
// Start activity
startActivity(intent)
}
or in Java:
void runDifferentActivity() {
// Different app package
String otherAppPackage = "comp.package.android.something.there";
// Activity name (from different App)
String otherAppActivity = "SecretActivity";
String action = String.format("%s.%s", otherAppPackage, otherAppActivity);
// Create Intent with action name
Intent intent = new Intent(action);
// Start activity
startActivity(intent);
}
Upvotes: 1