当我销毁我的应用程序时,logcat向我显示了这个错误:
java.lang.RuntimeException: Unable to start receiver com.examples.android.calendar.AlarmReceiver: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
at com.examples.android.calendar.AlarmReceiver.onReceive(AlarmReceiver.java:20)
我按照这样注册我的接收器:
@Override
protected void onDestroy() {
super.onDestroy();
try{
unregisterReceiver(mReceiver);
}catch(Exception e){
Log.v("hhhhhhhhhhhhhhhhhhhhh", e.getMessage());
}
}
@Override
protected void onResume() {
super.onResume();
mReceiver = new AlarmReceiver();
registerReceiver(
this.mReceiver,
new IntentFilter(
ConnectivityManager.CONNECTIVITY_ACTION));
}