本文整理匯總了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();
}
}