我试图展示通知类型的单挑,但我不能。我试过单向通知 - Android棒棒糖
final Notification.Builder notif = new Builder(getApplicationContext())
.setContentTitle(getString(R.string.title))
.setContentText(getString(R.string.text))
// .setTicker(getString(R.string.tick)) removed, seems to not show at all
// .setWhen(System.currentTimeMillis()) removed, match default
// .setContentIntent(contentIntent) removed, I don't neet it
.setColor(Color.parseColor(getString(R.color.yellow))) //ok
.setSmallIcon(R.drawable.ic_small) //ok
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
// .setCategory(Notification.CATEGORY_CALL) does not seem to make a difference
.setPriority(Notification.PRIORITY_MAX); //does not seem to make a difference
// .setVisibility(Notification.VISIBILITY_PRIVATE); //does not seem to make a difference
mNotificationManager.notify(Constants.NOTIFICATION_ID, notif.build());
通知只显示为在酒吧的一个图标。 我使用API 21 api21仿真器(不要使用L预览) 尝试安卓Theme.Holo.NoActionBar和android:Theme.Holo.NoActionBar.Fullscreen 而NotificationCompat.Builder
SDK的例子是不可用的。有谁知道如何做到这一点?
我做了它的工作将
.setDefaults(Notification.DEFAULT_VIBRATE)
是最好的方式?
如果这个为你工作时,你应该添加它作为答案。 – ProllyGeek 2014-12-08 23:47:38
请注意,抬头通知在观看媒体或使用任何应用程序时可能极其烦人 - 毫不奇怪,几乎所有应用程序都使用屏幕顶部。他们为屏幕的前三分之一投下了阴影(在我的8“Tegra Shield上测试过)如果你必须使用这些(天知道为什么),至少应该在你的应用中禁用它们一个选项,请! – 2015-02-21 05:13:02
@ user1499731 Android has本地支持禁用通知偷窥应用程序IIRC – Mygod 2016-03-06 00:02:57