Android: calls the system DownLoadManager to download files. android calls the System camera.
The Code contains detailed notes:
1/** 2 * This method calls the system's Download Manager 3 */4 public void downLoadApk (Context context, String url) {5/** 6 * here, the returned reference variable is a unique ID allocated by the system for the current download request. 7 * We can obtain the download task again through this ID, perform operations 8 * or query the download status and cancel the download. 9 */10 Uri uri = Uri. parse (url); // download connection 11 manager = (DownloadManager) context. getSystemService (context. DOWNLOAD_SERVICE); // obtain the system download management 12 requestApk = new DownloadManager. request (uri); // get the connection Request object 13 reques TApk. setAllowedNetworkTypes (DownloadManager. request. NETWORK_WIFI); // specify the network under which the download is made. Here I specify the WIFI network 14 requestApk. setDestinationInExternalPublicDir (context. getPackageName () + "/myDownLoad", "xiaoyuantong.apk"); // specify the path to save the downloaded file. Save it to the root directory 15 requestApk. setVisibleInDownloadsUi (true); // set to display the download interface 16 requestApk. allowScanningByMediaScanner (); // indicates that MediaScanner is allowed to scan this file, which is not allowed by default. 17 requestApk. setTitle ("xxx update and download"); // sets the message 18 requestApk in the notification bar during download. setDescription ("xxx update and download"); // you can specify 19 long downLoadId = manager. enqueue (requestApk); // starts the download. This method returns a unique ID20 allocated by the system for the current download request}