Java Code Examples for android.content.Intent#ACTION_MEDIA_SCANNER_STARTED

The following examples show how to use android.content.Intent#ACTION_MEDIA_SCANNER_STARTED . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void refreshMediaResource(){
    // Android 4.4
    if(Build.VERSION.SDK_INT>= 19){
        MediaScannerConnection.scanFile(this, new String[]{Environment.getExternalStorageDirectory().getAbsolutePath()},
                null, new MediaScannerConnection.OnScanCompletedListener() {
                    public void onScanCompleted(String path, Uri uri) {


                    }
                }
        );
    }else{
        IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
        intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
        intentFilter.addDataScheme("file");
        scanReceiver = new ScanSdFilesReceiver();
        registerReceiver(scanReceiver, intentFilter);
        sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory().getAbsolutePath())));
    }
}
 
Example 2
Source Project: Musicoco   File: MediaScanManager.java    License: Apache License 2.0 5 votes vote down vote up
public void startScan() {
    IntentFilter intentfilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
    intentfilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
    intentfilter.addDataScheme("file");
    context.registerReceiver(scanSdReceiver, intentfilter);

    String externalStoragePath = Environment.getExternalStorageDirectory().getPath();
    String path = externalStoragePath + "/";

    context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
            Uri.parse("file://" + path)));

}
 
Example 3
Source Project: LitePlayer   File: LocalFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void scanSDCard() {
	IntentFilter intentfilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
	intentfilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
	intentfilter.addDataScheme("file");
	mActivity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, 
			Uri.parse("file://"+ MusicUtils.getMusicDir())));
}
 
Example 4
Source Project: LitePlayer   File: DownloadService.java    License: Apache License 2.0 5 votes vote down vote up
private void scanSDCard() {
	IntentFilter intentfilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
	intentfilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
	intentfilter.addDataScheme("file");
	sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, 
			Uri.parse("file://"+ MusicUtils.getMusicDir())));
}
 
Example 5
Source Project: LitePlayer   File: MainActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void registerReceiver() {
	IntentFilter filter = new IntentFilter( Intent.ACTION_MEDIA_SCANNER_STARTED);
	filter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
	filter.addDataScheme("file");
	registerReceiver(mScanSDCardReceiver, filter);
}