我试图展示通知型的单挑,但我不能.我尝试了什么
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());
Run Code Online (Sandbox Code Playgroud)
通知仅显示为栏中的图标.我使用的是API 21 API 21仿真器(不要使用L预览)我曾尝试:
android:Theme.Holo.NoActionBar,
android:Theme.Holo.NoActionBar.Fullscreen
和NotificationCompat.Builder
SDK示例不可用.有谁知道怎么做?
我通过添加:
.setDefaults(Notification.DEFAULT_VIBRATE)
Run Code Online (Sandbox Code Playgroud)
这是最好的方法吗?