1
  val downloadManager = getSystemService(DOWNLOAD_SERVICE) as DownloadManager
            val request = DownloadManager.Request(Uri.parse("https://xxx.xx"))
            val filename = "update" + System.currentTimeMillis()
            val dir: String = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).toString() + "/"
            val file = File("$dir$filename.apk")
            request.setTitle("dm-test")
            request.setDescription("downing...")
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
            request.setMimeType("application/vnd.android.package-archive")
            request.setDestinationUri(Uri.fromFile(file))
            downloadManager.enqueue(request)

this code working in android api<33 is no problem, in android api=33 Notification no working

midai
  • 11
  • 3
  • Starting from Android 13 you must have permission to show notifications. https://developer.android.com/develop/ui/views/notifications/notification-permission – Ammar Abdullah Aug 25 '22 at 03:58
  • I have applied for this permission ``` when (PackageManager.PERMISSION_GRANTED) { ContextCompat.checkSelfPermission( this, Manifest.permission.POST_NOTIFICATIONS ) -> { Log.i("checkPermission","success") } else -> { requestPermissionLauncher.launch( Manifest.permission.POST_NOTIFICATIONS) } } ``` – midai Aug 25 '22 at 06:30
  • @midai Note that for permission requests to work, you need to make sure you also have those permissions registered in the manifest. Check that you registered the required permissions in the manifest file – Smile Nov 24 '22 at 12:36

2 Answers2

0

You can try once

request.setVisibleInDownloadsUi(true);

May be it can work

  • This is [deprecated](https://developer.android.com/reference/android/app/DownloadManager.Request#setVisibleInDownloadsUi(boolean)) – Malik Saifullah Sep 15 '22 at 18:00
0

If your app target OS is android 13 you need to request notification permission from the user.

You can refer the link below,

https://developer.android.com/develop/ui/views/notifications/notification-permission

Kishan Thakkar
  • 619
  • 6
  • 11