有人可以告诉我为什么以下在2.1而不是在2.2或3.1上工作正常吗?最终的Toast消息甚至显示MediaScanner已完成。
scanner = new MediaScannerConnection(this,
new MediaScannerConnection.MediaScannerConnectionClient () {
public void onMediaScannerConnected() {
Log.v("SCANNER"," CONNECTED: "+outputFile.getPath());
scanner.scanFile(outputFile.getPath(), null);
}
public void onScanCompleted(String path, Uri uri) {
if (path.equals(outputFile.getPath())) {
PhotoPager.this.runOnUiThread(new Runnable() {
public void run() {
Toast
.makeText(PhotoPager.this,
"Image has been saved",
Toast.LENGTH_SHORT)
.show();
}
});
}
scanner.disconnect();
}
}
);
答案 0 :(得分:0)
也许有点晚了,但我使用了这段代码(适用于2.3.3)
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));