You could check the packagename of the calling activity, but a full solution exists only with a cooperating calling activity, using one of the following alternatives:
- methods getCallingActivity()/getCallingPackage() work only if calling activity uses startActivityForResult() and not startActivity()
- method getInitialCaller() works from API Level 35, but only if the calling app has called ActivityOptions.setShareIdentityEnabled(true) or the launched activity has the same uid as the calling app or the launched activity is running in a package that is signed with the same key used to sign the platform.
- methods getLaunchedFromPackage()/getLaunchedFromUid() work from API Level 34, but only if the calling app has called ActivityOptions.setShareIdentityEnabled(true) or the launched activity has the same uid as the calling app or the launched activity is running in a package that is signed with the same key used to sign the platform.