在preference重新启动应用程序更改 [英] Restart application on preference changed

查看:149
本文介绍了在preference重新启动应用程序更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重新从 preferenceActivity 上preference改变了应用程序。我想:

I need to restart the application from PreferenceActivity on preference changed. I tried:

@Override
public void onSharedPreferenceChanged(SharedPreferences pref, String key) {
    System.exit(2);
}

但后重新启动设置不会被保存。中如何重新启动与preferences应用程序的任何想法都保存?结果
在此先感谢

but after restart settings are not saved. Any ideas of how to restart the app with preferences are saved?
Thanks in advance

推荐答案

(2);我会尝试

  this.finish(); 

完成()是调用停止活动。

finish() is the call to stop the activity.

启动你需要一个意图对象的活动

to start an activity you need an intent object

 Intent screenToBeShown = new Intent(myactivity.this, whateveractivityyouwant.class); 
 startActivity(screenToBeShown); 

希望这有助于。

这篇关于在preference重新启动应用程序更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆