2013-01-14 92 views

回答

5

为了显示当Service运行,你打电话通知:

startForeground(R.string.notification_id, myNotification); 

给予方法为您服务的ID,并且您已经创建了一个Notification


在任何时候,你Service可以更新用户看到通过使用相同的R.string.notification_id和发布新Notification什么:

NotificationManager notificationManager = 
     (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    notificationManager.notify(R.string.notification_id, myNotification); 

有关创建Notification,你需要阅读起来在Notification.Builderandroid docs here)上。

对于相关问题也有很好的答案:How exactly to use Notification.Builder?对于不重新发布他的答案抱歉,但它包含了很多代码,并且会将您排除在外。

+0

说,时间......当用户打开通知幻灯片时,他看到了当前时间。可能吗? – aclokay

+0

我已经更新了我的答案 –