kle*_*ens 10 notifications android
我需要编写一些应用程序,它将在后台完成一些工作.这个应用程序将从autostart运行,并没有任何开始gui.Gui可以通过点击通知进行呼叫,该通知将显示自动启动.我担心,当用户明确通知时,他失去了打电话给这个gui的机会.我的问题是,有没有办法阻止用户清除我的通知?
cja*_*cja 22
这是一个不允许用户清除它的通知.
Notification notification = new NotificationCompat.Builder(this)
.setTicker(r.getString(R.string.app_name))
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(r.getString(R.string.app_name))
.setAutoCancel(false)
.setOngoing(true)
.build();
Run Code Online (Sandbox Code Playgroud)
该setOngoing(true)调用实现这个,并setAutoCancel(false)停止从走开当用户点击该通知的通知.
如果卸载应用程序或通过调用取消或取消所有通知将被清除:http://developer.android.com/reference/android/app/NotificationManager.html#cancel( int )
| 归档时间: |
|
| 查看次数: |
8470 次 |
| 最近记录: |