2016-01-20 80 views
0

我使用此代碼顯示在我的智能手錶的通知:顯示通知自動

Notification n = new Notification.Builder(this) 
       .setContentTitle("Message") 
       .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.icon)) 
       .build(); 
     NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
     notificationManager.notify(0, n); 

我怎麼能自動顯示出它在我的智能手錶屏幕上創建的時候嗎?謝謝。

回答

0

你爲什麼不試試這個。

NotificationCompat.Builder builder = new NotificationCompat.Builder(this); 
     builder.setContentTitle("Message") 
       .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.icon)); 

     NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 
     nm.notify(UPDATE_NOTIFICATION_ID, builder.build()); 
1

叫單挑通知

每個開發者網站:如果你可以使用它:

用戶的活動是在全屏模式下(應用程序使用 fullScreenIntent)。

通知具有較高的優先級,並使用鈴聲或振動上運行Android 7.1(API級25)和下 設備。

該通知信道具有上運行的Android 8.0(API級26)和較高的器件高重要性。

,所以你需要做的是添加此:

builder.setPriority(Notification.PRIORITY_MAX);