Answer the question
In order to leave comments, you need to log in
Why does Intent return null?
public class RepeatingAlarmService extends BroadcastReceiver {
.............
RemoteViews rViews = new RemoteViews(gcontext.getPackageName(), R.layout.notification_layout);
rViews.setTextViewText(R.id.textView4, DB.getText());
Intent buttonsIntent = new Intent(gcontext, NotifyActivityHandler.class);
buttonsIntent.putExtra("do_action2", "yes");
PendingIntent pApp = PendingIntent.getActivity(gcontext, 4, buttonsIntent, 0);
rViews.setOnClickPendingIntent(R.id.buttonYes, pApp);
Intent buttonsIntent2 = new Intent(gcontext, NotifyActivityHandler.class);
buttonsIntent.putExtra("do_action2", "no");
PendingIntent pApp2 = PendingIntent.getActivity(gcontext, 5, buttonsIntent2, 0);
rViews.setOnClickPendingIntent(R.id.buttonNo, pApp2);
manger = (NotificationManager) gcontext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notify = new Notification.Builder(gcontext)
.setContentTitle("Напоминалка")
.setContentText(DB.getText())
.setTicker("Необходимо ответить на вопрос!").setWhen(System.currentTimeMillis() + DB.getServiceRepeatTime()) // java.lang.System.currentTimeMillis()
//.setContentIntent()
.setDefaults(Notification.DEFAULT_SOUND).setAutoCancel(true)
.setSmallIcon(R.drawable.appicon)
.setAutoCancel(false)
.setContent(rViews)
.build();
}
public class NotifyActivityHandler extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String action = this.getIntent().getExtras().getString("do_action2");
Log.i("","answer = "+action); /// здесь NULL
if (action != null) {
if (action.equals("yes")) {
Log.i("", "found (yes)");
} else if (action.equals("no")) {
Log.i("", "found (no)");
}
}
finish();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question