Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open from my app a specific activity from an other app?

I'm developing an app that opens other apps with intents and it works perfectly, but now i need to open a specific activity (or part of the app) and i don't know if it's even possible.

In this case i want to open Street View from the Google Cardboard app. I can't figure out or find the way of doing it.

Here is the intent im using (that works but does not full fill the task):

public void actionOpenCardboard(View view) {
    Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.samples.apps.cardboarddemo");
    if (launchIntent != null) {
        startActivity(launchIntent);
    }
}
like image 788
Mazal Avatar asked Sep 12 '25 12:09

Mazal


1 Answers

You can launch the Activity this way:

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
startActivity(intent);

Also, you may need to add android:exported="true" to the Activity's manifest from which you are invoking the above code.

like image 96
OBX Avatar answered Sep 14 '25 03:09

OBX