Answer the question
In order to leave comments, you need to log in
Why does onReceive immediately fire after registerReceiver?
Good afternoon.
Actually, the question is in the header,
as soon as I register the receiver to track changes in the connection to the Internet like this:
receiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if (NivaUtils.isConnected(context)) {
final ProgressDialog progress = NivaUtils.showProgressDialog(getActivity());
...
}
}
};
getActivity().registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION))
Answer the question
In order to leave comments, you need to log in
Receivers are generally crazy in terms of calls.
It is better to always check that the call occurred exactly for the action you need.
if(intent.getAction().equals("SOME_ACTION") {
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question