示例#1
0
  @Override
  public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.i(TAG, intent.toString());

    String action = intent.getAction();
    Uri uri = intent.getData();
    Log.i(TAG, "MediaMountReceiver" + uri);
    if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) {
      if (Util.hasExternalUpdateFile(uri) && Util.checkAllFileMD5(context)) {
        Log.d(
            TAG,
            "Name : UdiskUpgrade, Version : 1.0.0, Date : 2015-1-27, Publisher : Michael.Zhang, Revision : ");
        //				Intent intent1 = new Intent(context, UpgradeActivity.class);
        //				intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //				context.startActivity(intent1);
        Intent intent1 = new Intent("com.intent.action.UPGRADESERVICE");
        context.startService(intent1);
      }

      /*
       * Bundle args = new Bundle(); args.putString("path", path);
       * args.putStringArray("files", files); context.startService(new
       * Intent(context, UdiskUpgradeService.class).putExtras(args));
       */
    }
  }
示例#2
0
 @Override
 public void onReceive(Context context, Intent intent) {
   // TODO Auto-generated method stub
   String action = intent.getAction();
   if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) {
     Toast.makeText(context, "SDCard准备就绪", 0).show();
   } else if (Intent.ACTION_MEDIA_REMOVED.equals(action)) {
     Toast.makeText(context, "SDCard被拔掉", 0).show();
   } else if (Intent.ACTION_MEDIA_UNMOUNTED.equals(action)) {
     Toast.makeText(context, "SDCard被卸载", 0).show();
   }
 }
示例#3
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   String path = intent.getData().getPath();
   // only observe sdcard with default path: "/mnt/sdcard"
   String externalPath = Environment.getExternalStorageDirectory().getPath();
   if (Intent.ACTION_MEDIA_EJECT.equals(action) && externalPath.equalsIgnoreCase(path)) {
     mMounted = false;
   } else if (Intent.ACTION_MEDIA_MOUNTED.equals(action)
       && externalPath.equalsIgnoreCase(path)) {
     mMounted = true;
   }
   if (LOG) Log.v(TAG, "onReceive(" + intent + ") mMounted=" + mMounted);
 }