My app com.test.sample is invoked by an external app com.testExternal.outsideApp. The external app uses an intent to invoke the MainActivity of com.test.sample by calling the startActivityForResult. What I am looking for is a way to programmatically obtain the package name of the external app. I tried several ways like
String parentPackageName = this.getParent().getPackageName();
//This fails since the parent is always returning NULL.
String packageName = this.getIntent().getPackage();
//This returns the package name of the current application which is not what I want.
Is there any other way to get the package name of the caller app?