android生命周期onstop不一定会执行

Don't rely on onStop()because:

Note that this method may never be called, in low memory situations where the system does not have enough memory to keep your activity's process running after its onPause() method is called

More on Activity life cycle here.

Unregister your receiver in onPause():

@Override
protected void onPause() {
    super.onPause();

    unregisterReceiver(yourReceiver);
}

猜你喜欢

转载自blog.csdn.net/nimeghbia/article/details/80526890
今日推荐