Question

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

Was it helpful?

Solution

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
}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top