我要做的是用至少一个按钮发出重要通知(如果我想假设至少有2个,我会接受)。
public void notification() {
notification = new NotificationCompat.Builder(this);
notification.setStyle(new NotificationCompat.BigTextStyle(notification)
.bigText("lololololololoolololooloololoolooolloll")
.setBigContentTitle("Big Title")
.setSummaryText("Big Summary"))
//.setContentTitle("Title")
//.setContentText("Summary")
//.setTicker("Idk what this is really...")
.setDefaults(Notification.DEFAULT_ALL)
.setSmallIcon(R.drawable.holo_pressed_blue);
//vibrates when notification comes up
Notification note = notification.build();
note.defaults |= Notification.DEFAULT_VIBRATE;
manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, notification.build());
此外,如果它没有太大的麻烦,通过一个小通知,您如何将通知保留在状态栏中,并且它不允许用户将其从状态栏中删除,除非在应用程序中进行操作?
答案 0 :(得分:0)
您需要关注official Tutoria l。
您正在努力的CommonConstants
只是用户定义的常量:
请参阅https://code.google.com/p/android-source-browsing/source/browse/samples/training/notify-user/src/com/example/android/pingme/CommonConstants.java?repo=platform--development&name=jb-dev&r=fc0d593056584555189bc7f4aa36ca32ac9386b4或https://github.com/nRike/Android-simple-notification/blob/master/src/mx/androidtitlan/simplenotification/CommonConstants.java
获取您的packageName并附加" .EXTRA_MESSAGE"它等等。