창출을 나는 Intent alarmIntent = new Intent(this, MyNotification.class);
에서 nullpointer을 얻을하지만 방법이 문제를 해결하는 방법 아무 생각이 ...... 나는 누군가가 나를 도울 수있을 바랍니다 .. 9시 알람 일상을 설정 무엇을해야Nullpointer PendingIntent
BroadcastReceiver가 포함 된 MyNotification 클래스에서 알림을 설정할 수 있습니다.
이 (MainActivity에서)이 알람 관리기 클래스를 호출 :
Alarm setAlarm = new Alarm();
setAlarm.setRecurringAlarm();
나는 알람 관리기 (Alarm.class)을 설정하려는 클래스 :
public class Alarm extends Activity {
public void setRecurringAlarm() {
Log.i("Alarm", "Setting Recurring Alarm");
Calendar updateTime = Calendar.getInstance();
updateTime.set(Calendar.HOUR, 7);
updateTime.set(Calendar.MINUTE, 0);
updateTime.set(Calendar.SECOND, 0);
Intent alarmIntent = new Intent(this, MyNotification.class);
PendingIntent recurringDownload = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarms.cancel(recurringDownload);
alarms.setInexactRepeating(AlarmManager.RTC, updateTime.getTimeInMillis(), AlarmManager.INTERVAL_DAY , recurringDownload);
}
다음
내 모든 코드
}
로그캣 출력 :
08-07 22:43:38.079: E/AndroidRuntime(21476): FATAL EXCEPTION: main
08-07 22:43:38.079: E/AndroidRuntime(21476): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.weatherclothes/com.weatherclothes.MainActivity}: java.lang.NullPointerException
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.ActivityThread.access$600(ActivityThread.java:151)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.os.Looper.loop(Looper.java:155)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.ActivityThread.main(ActivityThread.java:5493)
08-07 22:43:38.079: E/AndroidRuntime(21476): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 22:43:38.079: E/AndroidRuntime(21476): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 22:43:38.079: E/AndroidRuntime(21476): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
08-07 22:43:38.079: E/AndroidRuntime(21476): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
08-07 22:43:38.079: E/AndroidRuntime(21476): at dalvik.system.NativeStart.main(Native Method)
08-07 22:43:38.079: E/AndroidRuntime(21476): Caused by: java.lang.NullPointerException
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.content.ComponentName.<init>(ComponentName.java:75)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.content.Intent.<init>(Intent.java:3655)
08-07 22:43:38.079: E/AndroidRuntime(21476): at com.weatherclothes.Alarm.setRecurringAlarm(Alarm.java:23)
08-07 22:43:38.079: E/AndroidRuntime(21476): at com.weatherclothes.MainActivity.onCreate(MainActivity.java:58)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.Activity.performCreate(Activity.java:5066)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
08-07 22:43:38.079: E/AndroidRuntime(21476): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
08-07 22:43:38.079: E/AndroidRuntime(21476): ... 11 more
PendingIntent 파이를 만들기 전에 컨텍스트가 null인지 확인하십시오 – Manu
와우, 실제로 컨텍스트가 null입니다. 해결 방법은 어떤 생각인가요? – TrulyUnlucky
컨텍스트를 사용하십시오. mContext = this; – Manu