如何添加媒体要MediaStore在Android 4.4奇巧SD卡的元数据

问题描述:

背景:在Android 4.4系统,谷歌决定应用程序应该没有写访问到SD卡的。

Background: In Android 4.4, Google decided that apps should not have write access to SD cards.

但是,应用程序可以写入/ SD卡/安卓/数据/应用程序包名称。

However, apps can write to /SDCard/Android/data/App Package Name.

所以这就是我所做的一切。我写了一个MP3文件到/安卓/数据/。那么我想这个MP3文件出现在Android的音乐播放器。

So this is what I've done. I have written an MP3 file to /Android/data/. I then want this MP3 file to show up in Android music players.

我已经试过以下...

I've tried the following...


sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
            + filePath))); 

和......


    MediaScannerConnection.scanFile(this,
          new String[] { file.toString() }, new String[] {"audio/*"},
          new MediaScannerConnection.OnScanCompletedListener() {
      public void onScanCompleted(String path, Uri uri) {
          Log.i("ExternalStorage", "Scanned " + path + ":");
          Log.i("ExternalStorage", "-> uri=" + uri);
      }
 });


ContentResolver.requestSync(CreateSyncAccount(context), MediaStore.AUTHORITY, null);

这两个将文件添加到MediaStore为文件中包含内容的URI://媒体/外部/文件/ XXXXX

both of these will add the file to the MediaStore as a file with a URI like content://media/external/file/xxxxx

但是,该文件不被添加作为音频。我可以更新MediaStore申报文件的音频,但文件的元数据将不会导入。

However, the file is not added as audio. I can update the MediaStore to declare the file as audio, but the file metadata isn't imported.

除了写我自己的标签阅读器,我怎么能得到媒体的扫描仪扫描的文件,并插入元数据,像它的内部存储器和pre-奇巧的SD卡?

Other than write my own tag reader, how can I get the media scanner to scan the file and insert metadata like it does on the internal memory and pre-KitKat SD cards?

我已经放弃了寻找一个解决方案。我不认为有一个,所以我已经提交了问题报告

I've given up looking for a solution. I do not think there is one, so I've filed an issue report.