在我boardcast接收器的的onReceive()方法,我怎么能说出意向的由来 [英] In my boardcast receiver 's onreceive() method, how can i tell the origin of the Intent

查看:134
本文介绍了在我boardcast接收器的的onReceive()方法,我怎么能说出意向的由来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在广播接收器的的onReceive()方法,我怎么能知道哪些应用程序的意图送我?

In the broadcast receiver's onReceive() method, how can I tell which app send me the Intent?

感谢您。

推荐答案

这是不是机器人如何使用意图的意图(没有双关语意)。但是,如果您发送的意图和你的广播接收的意图,您可以在使用意向setExtra(字符串,字符串)附加类发送意图的名称。你内部的onReceive,检查,看看是否额外的设置,如果是这样,请检查该值的预期类相匹配。

This is not the intent of how android uses Intents (no pun intended.). However, if you are sending the intent and your broadcaster is receiving the intent, you can use setExtra ( String, String) on the Intent to attach the name of the class sending the intent. Inside your onReceive, check to see if that extra is set and, if it is, check to see if the value matches your expected class.

这篇关于在我boardcast接收器的的onReceive()方法,我怎么能说出意向的由来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆