我正在使用sendBroadcast進行媒體文件掃描。然後我需要等到sendBroadcast完成後再完成。我如何在Android中執行此操作?如何等待sendBroadcast完成
我知道我可以用一個簡單的,而這裏的邏輯,但我正在尋找一個更好的辦法
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
// wait here till till do something completed
接收機
private BroadcastReceiver mediaScanner = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
// Do some thing here.
}
}
}
爲什麼不公佈答案** **在這裏? – 2012-06-28 12:17:42