Android - 显示通知,即使它已为应用程序禁用?
Android - show notifications even if it is disabled for the application?
在我的应用程序中,如果用户禁用 显示通知 选项 Android 系统将删除我的所有通知。但是它仍然显示 DU Battery Saver 应用程序,这里是
请帮我看看这个怎么实现?我也看到了 this link。
你能试试把优先级设置成MAX吗?
final Notification.Builder notification = new Builder(getApplicationContext())
.setContentTitle(getString(R.string.title))
.setContentText(getString(R.string.text))
.setColor(Color.parseColor(getString(R.color.yellow)))
.setSmallIcon(R.drawable.ic_small)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
.setPriority(Notification.PRIORITY_MAX);
mNotificationManager.notify(Constants.NOTIFICATION_ID, notification.build());
我认为这永远不可能,因为如果可以的话,Android 中的功能将是不必要的,因为每个开发人员都可以绕过它。
如果有任何可能性,我想 Android 团队会很快解决这个问题,因为这将是一个错误。
正如 Johan Lindkvist 的评论中所述,您禁用了错误应用的通知。
如果因为某些重要信息仍需要通知用户,可以使用Service
。然后用getApplicationContext()
显示一个Toast
。但是您应该在消息中包含您的应用程序名称,以便用户知道是谁发送了消息。
但这不是好的做法,因为只有当用户根据指南在您的应用程序中时,您才应该使用 Toast
s:
Your app should not create a dialog or toast if it is not currently on
screen. A dialog or toast should only be displayed as an immediate
response to the user taking an action inside of your app.
(https://developer.android.com/design/patterns/notifications.html)
如果用户关闭应用程序,则无法获得通知。 Android 也没有暴露任何 api 来控制 iit。
在我的应用程序中,如果用户禁用 显示通知 选项 Android 系统将删除我的所有通知。但是它仍然显示 DU Battery Saver 应用程序,这里是
请帮我看看这个怎么实现?我也看到了 this link。
你能试试把优先级设置成MAX吗?
final Notification.Builder notification = new Builder(getApplicationContext())
.setContentTitle(getString(R.string.title))
.setContentText(getString(R.string.text))
.setColor(Color.parseColor(getString(R.color.yellow)))
.setSmallIcon(R.drawable.ic_small)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
.setPriority(Notification.PRIORITY_MAX);
mNotificationManager.notify(Constants.NOTIFICATION_ID, notification.build());
我认为这永远不可能,因为如果可以的话,Android 中的功能将是不必要的,因为每个开发人员都可以绕过它。 如果有任何可能性,我想 Android 团队会很快解决这个问题,因为这将是一个错误。
正如 Johan Lindkvist 的评论中所述,您禁用了错误应用的通知。
如果因为某些重要信息仍需要通知用户,可以使用Service
。然后用getApplicationContext()
显示一个Toast
。但是您应该在消息中包含您的应用程序名称,以便用户知道是谁发送了消息。
但这不是好的做法,因为只有当用户根据指南在您的应用程序中时,您才应该使用 Toast
s:
Your app should not create a dialog or toast if it is not currently on screen. A dialog or toast should only be displayed as an immediate response to the user taking an action inside of your app.
(https://developer.android.com/design/patterns/notifications.html)
如果用户关闭应用程序,则无法获得通知。 Android 也没有暴露任何 api 来控制 iit。