I register broadcast receiver in Android's Application Class,but now my question is where to unregister that broadcast ?
public class MyApplication extends Application
{
@Override
public void onCreate() {
.....
// OTHER INITIALIZATIONS
initNetworkBR();
}
private void initNetworkBR() {
br = new BroadcastReceiver() {
....
};
IntentFilter filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(br, filter);
}
}
One suggestion is in your launcher activity or desired activity unregister that like this:
And implement
unregisterReceiver
method inMyApplication
class: