当前位置: 代码迷 >> Android >> Android MediaScanner扫描有关问题
  详细解决方案

Android MediaScanner扫描有关问题

热度:95   发布时间:2016-04-28 04:30:18.0
Android MediaScanner扫描问题
各位大侠,现在我有个问题,就是我想手动启动MediaScanner进行扫描,然后接收他的扫描开始和扫描结束广播,但是试了半天就是收不到广播,下面是我的代码,请问是什么问题

//请求扫描
Intent scanIntent  = new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("/mnt/storage/sdcard0/"));
//scanIntent.setData(Uri.fromFile(new File(sdDir)));
Log.v("test",Uri.parse("/mnt/storage/sdcard0/").toString());
sendBroadcast(scanIntent);

//注册监听,接收开始扫描广播
  <receiver 
            android:name = "com.example.test1.MyBorcastReceiver">
            <intent-filter
                android:priority="2147483647">
                <action android:name="android.intent.action.MEDIA_SCANNER_STARTED">
                </action>
            </intent-filter>
        </receiver>

------解决方案--------------------
你发的广播action是 Intent.ACTION_MEDIA_MOUNTED
接收的广播action是 android.intent.action.MEDIA_SCANNER_STARTED
两者不匹配,当然接收不到广播啊
  相关解决方案