Pregunta

Below is a simple way to communicate from App A to App B

// Call from App A
Intent intent = new Intent("some.Activity.inAppB");
startActivityForResult(intent, 0);

Now in the above statement, I want to trace from AOSP if the activity being called by Intent is from same app or different app.

Where in AOSP in particular I could get this information.

[Edit]
To be precise I would like to know if there is a way to track if "some.Activity.inAppB" belongs to the same app or a different app? If the activity is not in the same app is there a place where I can find out to which app does the activity belong to?

Thank you

¿Fue útil?

Solución

It turns out PackageManager.resolveActivity() seems to be the one I'm looking for.


Intent intent = new Intent("some.Activity.inAppB");
ResolveInfo ri = packageManagerInstance.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
if(ri != null) {
   ri.activityInfo.packageName // is the packageName for the activiy provided in the intent
}

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top