开发者

How to pause while the media scanner is running

开发者 https://www.devze.com 2023-03-18 06:20 出处:网络
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

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();
                }
            }
0

精彩评论

暂无评论...
验证码 换一张
取 消