开发者

broadcast receiver issue need help?

I created a broadcast receiver. After that in onReceive, I received an information and called a method in the class.

my question is when I call that method I want to call only once but why it calls more than one time?

Are there any way we can determine that onReceive receive only one ???

EDIT

my method that I call in onReceiver is update map location in class extend MapActivity

I also regis开发者_如何学Cter my broadcast service in manisfest.xml

I want to add comment to the answer but i can't i don't know why

how can we determine to our broadcast receiver to receiver only one?? thanks


you can maintain a bool variable and when you get call first time in the method, make this bool true and next time before calling the method you can put check there using this bool variable.

If you are not registering your receiver in the manifest file then you can use this bool value before registering the receiver.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜