下载管理器无法在真实设备上运行

时间:2019-06-13 09:49:30

标签: java android

 DownloadManager downloadManager;
                downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
                Uri uri = Uri.parse(link);
                DownloadManager.Request request = new DownloadManager.Request(uri);
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                Long reference = downloadManager.enqueue(request);

下载文件在模拟器中可以正常运行,但不能在真实设备上运行

1 个答案:

答案 0 :(得分:1)

您是否向AndroidManifest.xml添加了权限? 它发生在我身上,我就这样解决了。

<uses-permission android:name="android.permission.INTERNET" />