【问题标题】:How do you display big notfications with buttons?你如何用按钮显示大通知?
【发布时间】:2015-05-04 14:46:39
【问题描述】:

我要做的是用至少一个按钮发出大通知(如果我假设至少有 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());

另外,如果不是很麻烦,有一个小通知,你如何将通知保留在状态栏中,并且不允许用户将其从状态栏中删除,除非在应用程序中进行了操作?

【问题讨论】:

  • 最好将Notification.FLAG_ONGOING_EVENT 添加到您的Notification 的标志中。
  • @shkschneider 我做到了,问题是它在我的 android studio IDE 上无法识别“CommonConstants”,我查了一下,不幸的是没有解决方案。

标签: java android statusbar


【解决方案1】:
猜你喜欢
  • 2013-08-17
  • 1970-01-01
  • 1970-01-01
  • 2021-11-06
  • 2016-10-11
  • 2023-03-18
  • 1970-01-01
  • 2022-08-09
  • 1970-01-01
相关资源
最近更新 更多