android.content.Intent#ACTION_MEDIA_MOUNTED源码实例Demo

下面列出了android.content.Intent#ACTION_MEDIA_MOUNTED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: VCL-Android   文件: BaseTvActivity.java
@Override
protected void onResume() {
    super.onResume();
    //Handle network connection state
    IntentFilter networkfilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);

    IntentFilter storageFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
    storageFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    storageFilter.addDataScheme("file");

    registerReceiver(mExternalDevicesReceiver, networkfilter);
    registerReceiver(mExternalDevicesReceiver, storageFilter);
}
 
源代码2 项目: Dashchan   文件: CacheManager.java
private CacheManager() {
	handleGalleryShareFiles();
	syncCache();
	IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
	intentFilter.addDataScheme("file");
	MainApplication.getInstance()
			.registerReceiver(AndroidUtils.createReceiver((r, c, i) -> syncCache()), intentFilter);
	new Thread(this, "CacheManagerWorker").start();
}
 
源代码3 项目: edx-app-android   文件: MediaStatusReceiver.java
@Override
public void handleReceive(Context context, Intent intent) {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        return;
    }
    prefManager = new PrefManager(context, PrefManager.Pref.USER_PREF);
    final String username = loginPrefs.getUsername();
    final String hashedUsername = (username != null) ? Sha1Util.SHA1(username) : null;

    final String sdCardPath = intent.getDataString().replace("file://", "");
    final String action = intent.getAction();
    if (action != null) {
        boolean sdCardAvailable = false;
        switch (action) {
            case Intent.ACTION_MEDIA_REMOVED:
            case Intent.ACTION_MEDIA_UNMOUNTED:
                sdCardAvailable = false;
                handleSDCardUnmounted(hashedUsername, sdCardPath);
                break;
            case Intent.ACTION_MEDIA_MOUNTED:
                sdCardAvailable = true;
                handleSDCardMounted(context, hashedUsername);
                break;
        }
        EventBus.getDefault().postSticky(new MediaStatusChangeEvent(sdCardAvailable));
    }
}
 
源代码4 项目: Cangol-appcore   文件: StatusServiceImpl.java
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction() == Intent.ACTION_MEDIA_EJECT) {
        //do nothings
    } else if (intent.getAction() == Intent.ACTION_MEDIA_SHARED) {
        //do nothings
    } else if (intent.getAction() == Intent.ACTION_MEDIA_BAD_REMOVAL) {
        //do nothings
    } else if (intent.getAction() == Intent.ACTION_MEDIA_REMOVED) {
        notifyStorageRemove(context);
    } else if (intent.getAction() == Intent.ACTION_MEDIA_MOUNTED) {
        notifyStorageMount(context);
    }

}
 
源代码5 项目: edslite   文件: MediaMountedReceiver.java
@Override
public void onReceive(Context context, Intent intent) 
{
	Logger.debug("MediaMountedReceiver");
	LocationsManagerBase lm = _lm;
	if(lm == null)
		return;
	String mountPath = intent.getDataString();
       ExternalStorageLocation loc = mountPath != null ? new ExternalStorageLocation(context, "ext storage", mountPath, null) : null;
	try
	{
		Thread.sleep(3000);
	}
	catch (InterruptedException e)
	{
		e.printStackTrace();
	}
	switch (intent.getAction())
	{
		case UsbManager.ACTION_USB_DEVICE_ATTACHED:
			Logger.debug("ACTION_USB_DEVICE_ATTACHED");
			lm.updateDeviceLocations();
			LocationsManager.broadcastLocationAdded(context, loc);
			break;
		case Intent.ACTION_MEDIA_MOUNTED:
			Logger.debug("ACTION_MEDIA_MOUNTED");
			lm.updateDeviceLocations();
			LocationsManager.broadcastLocationAdded(context, loc);
			break;
		case Intent.ACTION_MEDIA_UNMOUNTED:
			Logger.debug("ACTION_MEDIA_UNMOUNTED");
			lm.updateDeviceLocations();
			LocationsManager.broadcastLocationRemoved(context, loc);
			break;
		case Intent.ACTION_MEDIA_REMOVED:
			Logger.debug("ACTION_MEDIA_REMOVED");
			lm.updateDeviceLocations();
			LocationsManager.broadcastLocationRemoved(context, loc);
			break;
		case UsbManager.ACTION_USB_DEVICE_DETACHED:
			Logger.debug("ACTION_USB_DEVICE_DETACHED");
			lm.updateDeviceLocations();
			LocationsManager.broadcastLocationRemoved(context, loc);
			break;
	}
}
 
源代码6 项目: RelaxFinger   文件: FloatingBallUtils.java
/**
 * 通知媒体库更新文件夹
 * @param context
 * @param filePath 文件夹
 *
 * */
public  static void scanFolder(Context context, String filePath) {
    Intent scanIntent = new Intent(Intent.ACTION_MEDIA_MOUNTED);
    scanIntent.setData(Uri.fromFile(new File(filePath)));
    context.sendBroadcast(scanIntent);
}
 
 方法所在类
 同类方法