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 . 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 check out the related API usage on the sidebar.
Example 1
Source File: FileManagerActivity.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
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 File: MediaScanManager.java    From Musicoco with 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 File: LocalFragment.java    From LitePlayer with 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 File: DownloadService.java    From LitePlayer with 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 File: MainActivity.java    From LitePlayer with 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);
}