------ Solution ------------------------- -------------------
generally in onDestroy () li canceled broadcast, or use service, ANR estimate is not receiving a broadcast things that should be received After the operation on the UI thread too long
------ Solution ------------------------------- -------------
you said ANR should not have registration or cancellation of broadcast receiver but because of the strong action after it
---- - Solution --------------------------------------------
Register broadcast in two ways, you can use the second, that is registered in AndroidManifest.xml
<receiver android:name=".ServiceBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
then implement ServiceBroadcastReceiver, receive the broadcast and do what you want to do. This is the entire program life cycle are present, you quit the program can continue to receive
------ reference -------------------- -------------------
Thank you for your reply. But I found that I now listen WifiManager.NETWORK_STATE_CHANGED_ACTION this broadcast, in my Activity onResume when each will receive once, even if this does not happen when the network status change things, how is this going ah? And I hope that at different stages in the procedure for the handling of this broadcast is not the same, because sometimes I will take the initiative to change the procedures WIFI connection.
------ reference --------------------------------------- < br>
yes. After receiving the broadcast, they pop up AlertDialog, because this time running in the background all on AlertDialog do not deal with, it appeared ANR it.
------ reference --------------------------------------- < br>
yes.
------ reference --------------------------------------- < br>
Thank you for your reply. But I found that I now listen WifiManager.NETWORK_STATE_CHANGED_ACTION this broadcast, in my Activity onResume when each will receive once, even if this does not happen when the network status change things, how is this going ah? And I hope that at different stages in the procedure for the handling of this broadcast is not the same, because sometimes I will take the initiative to change the procedures WIFI connection.
Then you need to check under your onCreate onStart onResume wifi has no right to operate
------ reference ----------------- ----------------------
Thank you for your reply. But I found that I now listen WifiManager.NETWORK_STATE_CHANGED_ACTION this broadcast, in my Activity onResume when each will receive once, even if this does not happen when the network status change things, how is this going ah? And I hope that at different stages in the procedure for the handling of this broadcast is not the same, because sometimes I will take the initiative to change the procedures WIFI connection.
Then you need to check under your onCreate onStart onResume has no right to operate wifi
WifiManager.getConnectionInfo () count? Otherwise gone
------ reference ------------------------------------ ---
to broadcast on the service inside
没有评论:
发表评论