Sometimes Android Broadcastreceiver Does Not Work
Solution 1:
I cannot be sure about the disconnects since you haven't provided any stack trace. But I am pretty sure the SMS_RECEIVED broadcast action is being broadcasted system-wide when you receive sms. Now if you do not receive SMS due to bad connection or no connection at all it's perfectly logical for the system not to trigger an SMS_RECEIVED action since no SMS was received.
As for the
is there any workaround to execute AsyncTask when my phone again get data network
you can implement another Broadcast Receiver that will listen for network changes but that doesn't seem such a good idea. You should try and reproduce the problem and check for any exceptions in your stack trace.
is something is wrong in the code.
Your receiver seems to be properly registered in your manifest,
the onReceive()
method seems to be properly launching the AsyncTask
,
the doInBackground
doesn't seem to have any problem and onPostExecute
(although the official example seems to omit any call to super) seems to be just fine.
Conclusion: Try to reproduce the problem and gather data from the stack trace as to what might cause the error (network overhead might be one the causes but that's just speculation).
Post a Comment for "Sometimes Android Broadcastreceiver Does Not Work"