下载管理器请求 setNotificationVisiblity
Download Manager Request setNotificationVisiblity
参考:https://developer.android.com/reference/android/app/DownloadManager.Request
setNotificationVisibility(int visiblity)
Control whether a system notification is posted by the download manager while this download is running or when it is completed. If enabled, the download manager posts notifications about downloads through the system NotificationManager
. By default, a notification is shown only when the download is in progress.
It can take the following values: VISIBILITY_HIDDEN
, VISIBILITY_VISIBLE
, VISIBILITY_VISIBLE_NOTIFY_COMPLETED
.
If set to VISIBILITY_HIDDEN
, this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
.
所以我想setNotificationVisiblity
到VISIBLITY_HIDDEN
。根据 docs 我需要在 AndroidManifest.xml
中设置权限。权限在哪里?
中找不到权限 android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
参考:https://developer.android.com/reference/android/Manifest.permission
此权限是否已从 Android 中删除?如果我未经许可设置 downaloadReq.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
,它会抛出一个 SecurityException
。那我该怎么办?
AndroidManifest.xml 文件中确实缺少您的许可。
只需添加以下行:
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
参考:https://developer.android.com/reference/android/app/DownloadManager.Request
setNotificationVisibility(int visiblity)
Control whether a system notification is posted by the download manager while this download is running or when it is completed. If enabled, the download manager posts notifications about downloads through the system
NotificationManager
. By default, a notification is shown only when the download is in progress.It can take the following values:
VISIBILITY_HIDDEN
,VISIBILITY_VISIBLE
,VISIBILITY_VISIBLE_NOTIFY_COMPLETED
.If set to
VISIBILITY_HIDDEN
, this requires the permissionandroid.permission.DOWNLOAD_WITHOUT_NOTIFICATION
.
所以我想setNotificationVisiblity
到VISIBLITY_HIDDEN
。根据 docs 我需要在 AndroidManifest.xml
中设置权限。权限在哪里?
android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
参考:https://developer.android.com/reference/android/Manifest.permission
此权限是否已从 Android 中删除?如果我未经许可设置 downaloadReq.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
,它会抛出一个 SecurityException
。那我该怎么办?
AndroidManifest.xml 文件中确实缺少您的许可。
只需添加以下行:
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>