我想展现一个通知型抬头,但我不能。我试过
I'm trying to show a notification-type heads-up but I could not. What I tried
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 preVIEW) 尝试机器人:Theme.Holo.NoActionBar和android:Theme.Holo.NoActionBar.Fullscreen 而NotificationCompat.Builder
The notification is shown only as an icon in the bar. I'm using api 21 on api21 emulator (not L preview) Tried android:Theme.Holo.NoActionBar and android:Theme.Holo.NoActionBar.Fullscreen And NotificationCompat.Builder
SDK的例子是不可用。没有人知道该怎么办呢?
Sdk examples are not available. does anyone know how to do it?
我做了它的工作增加
.setDefaults(Notification.DEFAULT_VIBRATE)
是最好的方式?
is the best way?
据Notifications,您需要设置振动或铃声进行单挑的工作。但是,这里有一个快速的黑客不需要VIBRATE权限产生抬头通知:
According to Notifications, you are required to set a vibrate or ringtone to make Heads-up work. However, here's a quick hack that doesn't require VIBRATE permission to produce a head-up notification:
notificationBuilder.setPriority(Notification.PRIORITY_HIGH)
.setVibrate(new long[0]);
上一篇:在Android的计划任务任务、计划、Android
下一篇:安卓:在overrided&QUOT隐藏键盘;完成"的EditText的关键preSS键盘、关键、QUOT、overrided