How to find Intent source in Android? [duplicate] How to find Intent source in Android? [duplicate] android android

How to find Intent source in Android? [duplicate]


A better way to do this would be to use Intent extras to pass parameters to the receiver.


If we look at the Intent.java class, we can see the members only included

private String mAction;private Uri mData;private String mType;private String mPackage;private ComponentName mComponent;private int mFlags;private HashSet<String> mCategories;private Bundle mExtras;

I do not think any of these members include sender information, making the answer to the question no. You couldn't do this for an arbitrary intent.


Might this be considered a workaround?

Have A & B call startActivityForResult instead of startActivity, then you can call getCallingActivity().getClassName() to retrieve the source.