-1
這是我在android studio中寫的。它不工作。沒有通知彈出。爲什麼這個通知代碼不起作用?
NotificationManager notificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent i_mainActivity=new Intent(this,MainActivity.class);
PendingIntent p_mainActivity=PendingIntent.getActivity(this, 0, i_mainActivity, 0);
NotificationCompat.Builder notification_popup=new NotificationCompat.Builder(this)
.setContentTitle("An Alarm is going on")
.setContentText("Click to stop")
.setContentIntent(p_mainActivity)
.setAutoCancel(true);
int id=001;
notificationManager.notify(id,notification_popup.build());
請解釋「不工作」的含義。你的症狀是什麼? – CommonsWare