How to pause while the media scanner is running
I have an application that shows, plays and delete videos. I want to know that how to pause the current thread or processing while the media scanner is running. it takes about 4 to 7 seconds for media sc开发者_StackOverflow社区anner to complete its activity..
any suggestions
If I understood you correctly you just need to implement the OnScanCompletedListener.
If not, add some code to clarify your question.
So if you want to know when the media scanner is done you have to register BroadcastReceiver which will listen for ACTION_MEDIA_SCANNER_FINISHED. Here is good presentation that gives good explanation of Intent, IntentFilter and BroadcastReceiver.
I use this code:)
while(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
System.out.println("wait sdcard mount.");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
精彩评论