Java Code Examples for android.app.Activity#recreate()

The following examples show how to use android.app.Activity#recreate() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private static void restartActivity(Activity activity) {
    if (Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
        Log.v(LOG_TAG, "About to restart " + activity.getClass().getSimpleName());
    }
    // You can't restart activities that have parents: find the top-most activity
    while (activity.getParent() != null) {
        if (Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
            Log.v(LOG_TAG, activity.getClass().getSimpleName()
                    + " is not a top level activity; restarting "
                    + activity.getParent().getClass().getSimpleName() + " instead");
        }
        activity = activity.getParent();
    }
    // Directly supported by the framework!
    activity.recreate();
}
 
Example 2
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
  final Activity activity = getActivity();
  if (activity == null) return false;

  activity.recreate();

  if (TextSecurePreferences.LANGUAGE_PREF.equals(preference.getKey())) {
    Intent intent = new Intent(activity, KeyCachingService.class);
    intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT);
    activity.startService(intent);
  }

  return new ListSummaryListener().onPreferenceChange(preference, newValue);
}
 
Example 3
Source Project: BaldPhone   File: TutorialFragment2.java    License: Apache License 2.0 5 votes vote down vote up
private void clickedEffect(TextView v) {
    longPressesFlag = (int) v.getTag();
    applyDuoToFlag();
    sharedPreferences.edit()
            .putBoolean(BPrefs.VIBRATION_FEEDBACK_KEY, longPressesFlag > 0)
            .putBoolean(BPrefs.LONG_PRESSES_KEY, longPressesFlag > 0)
            .putBoolean(BPrefs.LONG_PRESSES_SHORTER_KEY, longPressesFlag == 1)
            .putBoolean(BPrefs.TOUCH_NOT_HARD_KEY, longPressesFlag == 0)
            .apply();
    Activity activity = getActivity();
    if (activity != null) {
        activity.recreate();
    }

}
 
Example 4
/** force all open activity to recreate */
public static void recreate(Activity child) {
    Activity context = child;
    while (context != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            context.recreate();
        } else {
            // https://stackoverflow.com/questions/11495130/android-recreate-functions-in-api-7
            context.startActivity(new Intent(context, context.getClass()));
            context.finish();
        }
        context = context.getParent();
    }
}
 
Example 5
@OnClick(R.id.switch_to_vi)
void switchToVI() {
    if(mIsEnglish) {
        Activity activity = getActivity();
        if (activity != null) {
            LocaleHelper.setLocale(activity, "vi");
            activity.recreate();
        }
    }

}
 
Example 6
public static void restartActivity(Activity activity)
{
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
	    activity.recreate();
	else
	{
	    Intent intent = activity.getIntent();
	    activity.overridePendingTransition(0, 0);
	    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
	    activity.finish();
	    activity.overridePendingTransition(0, 0);
	    activity.startActivity(intent);
	}
}
 
Example 7
public static void registerPreferenceUpdater(Activity activity) {

            if (isPreferenceChanged.containsKey(mTag) && sPreference && isPreferenceChanged.get(mTag)) {

                activity.recreate();
                sPreference = false;
            }
    }
 
Example 8
Source Project: pybbsMD   File: ActivityUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void recreate(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    } else {
        Intent intent = activity.getIntent();
        intent.setClass(activity, activity.getClass());
        activity.startActivity(intent);
        activity.finish();
        activity.overridePendingTransition(0, 0);
    }
}
 
Example 9
Source Project: coolreader   File: UIHelper.java    License: MIT License 5 votes vote down vote up
/**
 * Recreate the activity
 * 
 * @param activity
 *            target activity
 */
@SuppressLint("NewApi")
public static void Recreate(Activity activity) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
		activity.recreate();
	else {
		activity.finish();
		activity.startActivity(activity.getIntent());
	}
	CheckScreenRotation(activity);
	CheckKeepAwake(activity);
}
 
Example 10
static void reloadActivity(final Activity activity, @SuppressWarnings("SameParameterValue") boolean newIntent)
{
    if (activity == null)
        return;

    if (newIntent)
    {
        new Handler(activity.getMainLooper()).post(new Runnable() {

            @Override
            public void run() {
                try {
                    Context context = activity.getApplicationContext();

                    Intent intent = activity.getIntent();
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);

                    activity.finish();
                    activity.overridePendingTransition(0, 0);

                    context.startActivity(intent);
                    //activity.overridePendingTransition(0, 0);
                } catch (Exception e) {
                    PPApplication.recordException(e);
                }
            }
        });
    }
    else
        activity.recreate();
}
 
Example 11
@Override
public void onActivityResumed(Activity activity) {
    top = activity;
    // should never be null
    long l = activities.get(activity);
    if (l < ProtifyApplication.getResourceInstallTime())
        activity.recreate();
}
 
Example 12
Source Project: wakao-app   File: MethodsCompat.java    License: MIT License 4 votes vote down vote up
@TargetApi(11)
public static void recreate(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    }
}
 
Example 13
@TargetApi(11)
public static void recreate(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    }
}
 
Example 14
Source Project: android-app   File: Themes.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static void checkTheme(Activity activity) {
    Theme appliedTheme = appliedThemes.get(activity);
    if(appliedTheme != theme) activity.recreate();
}
 
Example 15
Source Project: NMSAlphabetAndroidApp   File: Util.java    License: MIT License 4 votes vote down vote up
public static void restartActivity(Activity activity){
    if(activity != null) {
        activity.recreate();
    }
}
 
Example 16
public static void clearThemeOverlays(Activity activity) {
  themeOverlays.clear();
  activity.recreate();
}
 
Example 17
Source Project: materialistic   File: AppUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static void restart(Activity activity, boolean transition) {
    activity.recreate();
}
 
Example 18
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void restartActivity(final Activity activity) {
    activity.recreate();
}
 
Example 19
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void recreateActivity(Activity activity) {
    activity.recreate();
}
 
Example 20
@TargetApi(11)
private static void recreateActivity(Activity a) {
    if (a != null) a.recreate();
}