小编use*_*384的帖子

Android - DownloadManager/BroadcastReceiver多次调用

我正在使用DownloadManager来处理我的应用程序中的下载,我想在下载完成时通知用户.

我正在使用运行良好的下面的代码

 public void downloaddownload(View v){
        View v2 = (View) v.getParent();
        TextView urlView = (TextView) v2.findViewById(R.id.url);
        String urlString = (String) urlView.getText().toString();
        TextView artistView2 = (TextView) v2.findViewById(R.id.artist);
        final String artistString = (String) artistView2.getText().toString();
        TextView titleView2 = (TextView) v2.findViewById(R.id.title);
        final String titleString = (String) titleView2.getText().toString();

        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(urlString));
        request.setDescription(titleString);
        request.setTitle(artistString);
        // in order for this if to run, you must use the android 3.2 to compile your app
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        }
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MUSIC + "/folder", titleString …
Run Code Online (Sandbox Code Playgroud)

java android download-manager broadcastreceiver android-download-manager

8
推荐指数
1
解决办法
5303
查看次数