开发者

Is it possible to get any info about what application sent an intent?

Is it possible to tell what application sent an intent, or any kind of related information?

Here is an example scenario: My application is selected from a Share menu in some other app. My app then receives the ACTION_SEND intent, with some content to share, like some t开发者_运维知识库ext.

Then, I would like to do different things based on where that text came from. If it came from the Facebook app, I would like to do such and such. If it came from the Twitter app, I would like to handle it slightly differently.

Is any information available to identify the sender to the receiver?

Thanks


Don't think it's possible since the Intent class in Java does not have a private member to hold this data, see a discussion on a very similar question here.


in your receiver Activity class, have you tried calling getApplication(), and then furthermore getApplicationInfo()? Once you do that you can get details of the application which calls creates the intent for the receiver.

so something like this:

ApplicationInfo appInfo = getApplication().getApplicationInfo();

You can then access extra information and meta data of the application which called the receiver.

Im not 100% sure if this'll work but give it a shot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜