0

下面的代码显示 MediaScanner 已在 sdcard 上启动,它弹出后为什么?发生了什么?

if(intent.getDataString().equals("file:///mnt/extsd"))
        {
            if(Intent.ACTION_MEDIA_SCANNER_STARTED.equals(intent.getAction()))
            {
                //Media scanner is started
            }
            else if(Intent.ACTION_MEDIA_SCANNER_FINISHED.equals(intent.getAction()))
            {
            }
        }
4

1 回答 1

1

可能这个问题会有所帮助它关于/mnt/extsd以及如何正确使用SD卡(手段Environment.getExternalStorageDirectory())。您还必须检查 SD 卡的状态。我的意思是:

boolean isExternalStorageWriteable = false, isExternalStorageReadable = false;
// Check SD Card for Read/Write
if (Environment.MEDIA_MOUNTED.equals(state)) {
    // We can read and write the media
    isExternalStorageWriteable = true;
    isExternalStorageReadable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    // We can only read the media
    isExternalStorageReadable = true;
} else {
    // Something else is wrong. It may be one of many other states, but
    // all we need
    // to know is we can neither read nor write
}
于 2013-03-06T15:45:12.260 回答