本文整理汇总了Java中android.app.Activity.recreate方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.recreate方法的具体用法?Java Activity.recreate怎么用?Java Activity.recreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.recreate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recreate
import android.app.Activity; //导入方法依赖的package包/类
/**
* Helper method to recreate the Activity. This method should be called after a Locale change.
* @param activity the Activity that will be recreated
* @param animate a flag indicating if the recreation will be animated or not
*/
public static void recreate(Activity activity, boolean animate) {
if (animate) {
Intent restartIntent = new Intent(activity, activity.getClass());
Bundle extras = activity.getIntent().getExtras();
if (extras != null) {
restartIntent.putExtras(extras);
}
ActivityCompat.startActivity(
activity,
restartIntent,
ActivityOptionsCompat
.makeCustomAnimation(activity, android.R.anim.fade_in, android.R.anim.fade_out)
.toBundle()
);
activity.finish();
} else {
activity.recreate();
}
}
示例2: onResume
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
onShowDonationChanged();
Preference preference = getPreferenceScreen().findPreference("brevent_about_developer");
if (!SimpleSu.hasSu() && AppsDisabledFragment.isAdbRunning()) {
preference.setSummary(R.string.brevent_about_developer_adb);
} else {
preference.setSummary(null);
}
preference.setOnPreferenceClickListener(this);
if (BuildConfig.RELEASE) {
Activity activity = getActivity();
BreventApplication application = (BreventApplication) activity.getApplication();
double donation = BreventApplication.getDonation(application);
int playDonation = BreventApplication.getPlayDonation(application);
String amount = DecimalUtils.format(donation + playDonation);
if (mAmount == null) {
mAmount = amount;
} else if (!Objects.equals(mAmount, amount)) {
activity.recreate();
}
}
}
示例3: onChangeHarvestMessage
import android.app.Activity; //导入方法依赖的package包/类
@WorkMessageHandler(ChangeHarvestMessage.class)
public void onChangeHarvestMessage(ChangeHarvestMessage message) {
if (message.localId == mEvent.mLocalId) {
return;
}
final Activity activity = getActivity();
GameHarvest harvest = GameDatabase.getInstance().getEventByLocalId(message.localId);
if (harvest != null) {
activity.getIntent().putExtra(HarvestActivity.EXTRA_HARVEST, harvest);
activity.getIntent().putExtra(HarvestActivity.EXTRA_NEW, false);
activity.recreate();
}
}
示例4: createExitRevealEffect
import android.app.Activity; //导入方法依赖的package包/类
public void createExitRevealEffect(final Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final View rootView = ((ViewGroup)activity.findViewById(Window.ID_ANDROID_CONTENT)).getChildAt(0);
Animator revealEffect = createRevealEffect(rootView, Status.EXIT);
revealEffect.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
rootView.setVisibility(View.INVISIBLE);
activity.recreate();
}
});
revealEffect.start();
} else {
activity.recreate();
}
}
示例5: onPreferenceChange
import android.app.Activity; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if ("brevent_language".equals(preference.getKey())) {
Activity activity = getActivity();
String language = String.valueOf(newValue);
if ("auto".equals(language)) {
language = "";
}
if (LocaleUtils.setOverrideLanguage(activity, language)) {
getArguments().putBoolean(LOCALE_CHANGED, true);
activity.recreate();
}
}
return true;
}
示例6: registerPreferenceUpdater
import android.app.Activity; //导入方法依赖的package包/类
public static void registerPreferenceUpdater(Activity activity) {
if (isPreferenceChanged.containsKey(mTag) && sPreference && isPreferenceChanged.get(mTag)) {
activity.recreate();
sPreference = false;
}
}
示例7: recreate
import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(11)
public static void recreate(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
activity.recreate();
}
}