コード例 #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)
       || 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();
   }
 }
コード例 #2
0
  @Override
  public void onReceive(Context context, Intent intent) {
    Log.d(
        Constants.TAG,
        "[ColorThemeChangedReceiver onReceive]---intent.getAction()=" + intent.getAction());
    if (intent.getAction().equals("action.flyaudio.colortheme")) {
      Log.e("lixuanbright", "action.flyaudio.colortheme====");
      //			AppWidgetDao dao = new AppWidgetDao(context);
      //			List<Integer> appWidgetIds = dao.getAppWidgetIds();
      int[] appWidgetIds = AppWidgetDao.getAllAppWidgetId(context);
      appWidgetManager = AppWidgetManager.getInstance(context);
      for (int appWidgetId : appWidgetIds) {
        remoteViews = SwitchWidget.initRemoteViews(context, appWidgetId);
        //  restore shortcut had been set
        SwitchWidget.dataRestore(context, appWidgetId, remoteViews, false);

        appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
      }
      //			dao.close();
    }
    if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
      Log.e("lixuanbright", "主题:Intent.ACTION_LOCALE_CHANGED===");
      /*			int[] appWidgetIds = AppWidgetDao.getAllAppWidgetId(context);
      appWidgetManager = AppWidgetManager.getInstance(context);
      for (int appWidgetId : appWidgetIds) {
       remoteViews =SwitchWidget.initRemoteViews(context, appWidgetId);
      	//  restore shortcut had been set
      	SwitchWidget.dataRestore(context, appWidgetId , remoteViews, false);

      	appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
      }*/
    }
  }
コード例 #3
0
  @Override
  public void onReceive(final Context context, final Intent intent) {
    final String intentAction = intent.getAction();
    if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intentAction)) {
      Log.i(TAG, "Package has been replaced: " + context.getPackageName());
      // Need to restore additional subtypes because system always clears additional
      // subtypes when the package is replaced.
      RichInputMethodManager.init(context);
      final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
      final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes(context);
      richImm.setAdditionalInputMethodSubtypes(additionalSubtypes);
      LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context);
    } else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) {
      Log.i(TAG, "Boot has been completed");
      LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context);
    } else if (IntentCompatUtils.is_ACTION_USER_INITIALIZE(intentAction)) {
      Log.i(TAG, "User initialize");
      LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context);
    } else if (Intent.ACTION_LOCALE_CHANGED.equals(intentAction)) {
      Log.i(TAG, "System locale changed");
      KeyboardLayoutSet.onSystemLocaleChanged();
    }

    // The process that hosts this broadcast receiver is invoked and remains alive even after
    // 1) the package has been re-installed, 2) the device has just booted,
    // 3) a new user has been created.
    // There is no good reason to keep the process alive if this IME isn't a current IME.
    final InputMethodManager imm =
        (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    // Called to check whether this IME has been triggered by the current user or not
    final boolean isInputMethodManagerValidForUserOfThisProcess =
        !imm.getInputMethodList().isEmpty();
    final boolean isCurrentImeOfCurrentUser =
        isInputMethodManagerValidForUserOfThisProcess
            && UncachedInputMethodManagerUtils.isThisImeCurrent(context, imm);
    if (!isCurrentImeOfCurrentUser) {
      final int myPid = Process.myPid();
      Log.i(TAG, "Killing my process: pid=" + myPid);
      Process.killProcess(myPid);
    }
  }