I don't understand why i have a NullPointerException when i create my pendingIntent instance like this :
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if(requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
Alarm alarm = (Alarm) intent.getSerializableExtra(AlarmAdapter.ALARM_INSTANCE);
int position = intent.getIntExtra(AlarmAdapter.ITEM_POSITION_ADAPTER, 0);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), position, intentListAlarmActivityToWakeUpActivity, 0);
//setAlarm(alarm.getHourOfAlarm(), alarm.getMinutesOfAlarm(), position);
mListOfAlarm.get(position).setData(alarm);
mAlarmAdapter.notifyDataSetChanged();
}
}
the PendingIntent.getActivity(...) return null... Here is the stack trace in Android Studio:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1986, result=-1, data=Intent { (has extras) }} to activity {com.selfieproduction.yacire.selfwakeup/com.selfieproduction.yacire.selfwakeup.ListAlarmActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3432)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3475)
at android.app.ActivityThread.access$1300(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.PendingIntent.getActivity(PendingIntent.java:261)
at android.app.PendingIntent.getActivity(PendingIntent.java:224)
at com.selfieproduction.yacire.selfwakeup.ListAlarmActivity.onActivityResult(ListAlarmActivity.java:221)
at android.app.Activity.dispatchActivityResult(Activity.java:5446)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3428)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3475)
at android.app.ActivityThread.access$1300(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
Sorry for All,
My intent was false... Thanks to Rey Pham for his comment.