質問

私はAndroidアプリケーションに取り組んでいます。

ダウンロードが終了した場所を知るためにBroadcastRecieverを使用しています。

        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(urlString));
    request.setDescription(artistString);
    request.setTitle(titleString);
    // 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 + "/Tunesto", titleString + " - " + artistString + ".mp3");

    Toast.makeText(mainContext, "Downloading " + titleString + " - " + artistString, Toast.LENGTH_SHORT).show();

    // get download service and enqueue file
    DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
    manager.enqueue(request);
.

その後、ダウンロード終了時にトーストを表示するには、この方法でこれを使用します。

onComplete = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            String info = "";
            info = info + " - " + intent.getStringExtra(DownloadManager.COLUMN_DESCRIPTION);
            info = info + " - " + intent.getStringExtra(DownloadManager.COLUMN_TITLE);
            info = info + " - " + intent.getStringExtra(DownloadManager.COLUMN_ID);
            info = info + " - " + intent.getStringExtra(DownloadManager.COLUMN_LOCAL_FILENAME);
            info = info + " - " + intent.getStringExtra(DownloadManager.COLUMN_MEDIA_TYPE);
            info = info + " - " + intent.getStringExtra(DownloadManager.COLUMN_TOTAL_SIZE_BYTES);
            info = info + " - " + intent.getDataString();
            info = info + " - " + intent.getType();
            info = info + " - " + intent.EXTRA_TITLE;
            info = info + " - " + intent.EXTRA_TEXT;

            //Toast.makeText(mainContext, Integer.valueOf(dlCount) + "  Download \"" + titleString + " - " + artistString + "\" completed", Toast.LENGTH_LONG).show();
            Toast.makeText(mainContext, info + "Download completed", Toast.LENGTH_LONG).show();
        }
     };

    registerReceiver(onComplete, new IntentFilter(
            DownloadManager.ACTION_DOWNLOAD_COMPLETE));
.

あなたが見ることができるように、私は情報文字列内の説明とタイトルを取得するためにすべてを試してみましたが、NULLよりも他には何も示さない(乾杯...

これらの情報を取得する方法についてのヒントを教えてください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top