Esempio n. 1
0
 @Override
 public void onReceive(Context context, Intent intent) {
   final String action = intent.getAction();
   if (Intent.ACTION_TIME_TICK.equals(action)
       || Intent.ACTION_TIME_CHANGED.equals(action)
       || Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
     mHandler.sendEmptyMessage(1);
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   final String action = intent.getAction();
   if (Intent.ACTION_TIME_TICK.equals(action)
       || Intent.ACTION_TIME_CHANGED.equals(action)
       || Intent.ACTION_TIMEZONE_CHANGED.equals(action)
       || Intent.ACTION_LOCALE_CHANGED.equals(action)) {
     if (Intent.ACTION_LOCALE_CHANGED.equals(action)
         || Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
       // need to get a fresh date format
       mDateFormat = null;
     }
     updateClock();
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   final String action = intent.getAction();
   if (Intent.ACTION_PACKAGE_CHANGED.equals(action)
       || Intent.ACTION_PACKAGE_REMOVED.equals(action)
       || Intent.ACTION_PACKAGE_ADDED.equals(action)) {
     Log.i(TAG, "action: " + action);
     final String packageName = intent.getData().getSchemeSpecificPart();
     final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
     int op = PackageUpdatedTask.OP_NONE;
     if (packageName == null || packageName.length() == 0) {
       // they sent us a bad intent
       return;
     }
     if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
       op = PackageUpdatedTask.OP_UPDATE;
     } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
       if (!replacing) {
         op = PackageUpdatedTask.OP_REMOVE;
       }
     } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
       if (!replacing) {
         op = PackageUpdatedTask.OP_ADD;
       } else {
         op = PackageUpdatedTask.OP_UPDATE;
       }
     }
     mHandler.post(new PackageUpdatedTask(op, new String[] {packageName}));
   } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {
     Log.i(TAG, "ACTION_EXTERNAL_APPLICATIONS_AVAILABLE");
     String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
     int op = PackageUpdatedTask.OP_ADD;
     mHandler.post(new PackageUpdatedTask(op, packages));
   } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
     Log.i(TAG, "ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE");
     String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
     int op = PackageUpdatedTask.OP_REMOVE;
     mHandler.post(new PackageUpdatedTask(op, packages));
   } else if (Intent.ACTION_TIME_TICK.equals(action)
       || Intent.ACTION_TIME_CHANGED.equals(action)
       || Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
     timeChanged();
   } else if (FavoritesModel.ACTION_FAVOTITE_UPDATE.equals(action)) {
     Log.i(TAG, "ACTION_FAVOTITE_UPDATE");
     FavoritesData.saveFavoritesToDatabase(mContext);
     FavoritesData.sort();
   }
 }