zoukankan      html  css  js  c++  java
  • android中广播接收SD卡状态

    mReceiver = new BroadcastReceiver() {

    //add by mengmeng.chen begin

    public void onReceive(Context context, Intent intent) {

    String action = intent.getAction();

    if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {

    loadDir((String)mPath.getText());

    }else if (action.equals(Intent.ACTION_MEDIA_UNMOUNTED) || action.equals(Intent.ACTION_MEDIA_BAD_REMOVAL)||action.equals(Intent.ACTION_MEDIA_EJECT)) {

    loadDir(FileUtils.ROOTPATH);

    }

    }

    };

    filter = new IntentFilter();

    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);

    filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);

    filter.addAction(Intent.ACTION_MEDIA_EJECT);

    filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);

     filter.addDataScheme("file");

    registerReceiver(mReceiver, filter);// registerReceiver(BroadcastReceiver receiver, IntentFilter filter) ,第一个参数是我们要处理广播的 BroadcastReceiver (广播接收者,可以是系统的,也可以是自定义的);第二个参数是意图过滤器。

    }

  • 相关阅读:
    [HEOI2016/TJOI2016]求和——第二类斯特林数
    RMAN备份脚本
    CF724E Goods transportation
    RMAN备份脚本--DataGuard primary
    [CEOI2017]Mousetrap
    healthcheck
    [学习笔记]斯特林数
    database.sql
    HDU 4372 Count the Buildings——第一类斯特林数
    orac
  • 原文地址:https://www.cnblogs.com/dreamy890322/p/3148659.html
Copyright © 2011-2022 走看看