cwa*_*wai 7 android android-notifications
是否可以通过任何方式在应用程序通知中打开横幅设置(显示在状态栏顶部)?

<pre><code>
// send notification to NotificationManager
Notification.Builder notificationBuilder =new Notification.Builder(context);
notificationBuilder.setSmallIcon(R.drawable.icon_32x32)
.setLargeIcon(bitmap)
.setContentTitle("title")
.setContentText("content")
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_HIGH)
.setCategory(Notification.CATEGORY_MESSAGE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
notificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
}
NotificationManager notificationManager =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(id, notificationBuilder.build());
</code></pre>
Run Code Online (Sandbox Code Playgroud)
通常,对于需要获得用户权限的设置,您可以在 java 类中执行此操作。
您可以将用户发送到设置,以便他们可以授予您所需的权限。然而,在我看来,您正在寻找平视通知。如果是这样的话:
https://developer.android.com/guide/topics/ui/notifiers/notifications.html#Heads-up
简而言之,在通知管理器类中设置高优先级。
| 归档时间: |
|
| 查看次数: |
3697 次 |
| 最近记录: |