6
如何獲得擡頭通知。有了下面的代碼,我只能看到狀態欄上的三個點和通知欄中的通知。如何顯示擡頭通知android
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 , intent,PendingIntent.FLAG_ONE_SHOT);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.bip);
Uri defaultSoundUri=RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.bip)
.setContentTitle("Temp")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
嗯,這是一個愚蠢的一個。需要設置選擇我的應用程序並更改應用程序通知設置。之後,擡頭通知可見。但是,Facebook和其他應用如何處理這種設置擰緊。 – user1837779
請看看他們的文檔:http://developer.android.com/guide/topics/ui/notifiers/notifications.html – DNC