Android - java.lang.RuntimeException: Unable to pause activity java.lang.IllegalArgumentException: Receiver not registered:

Receiver not registered

這是突然發生的問題。

我已經在 onResume及onPause加入對映的registerReceiver及unregisterReceiver ,但還是發生了這個錯誤,所以就只好在unregisterReceiver 前後加上try catch 防呆

@Override
protected void onResume() {
   super.onResume();
   //截取推播更新通知
   registerReceiver(mReceiver, new IntentFilter(mFilter));
}

@Override
protected void onPause() {
   super.onPause();
   try {
      unregisterReceiver(mReceiver);
   }catch(Exception ex) {
      ex.printStackTrace();
   }
}