如何通过首选项打开手机设置页面? [英] How to open up phones settings page through preferences?
本文介绍了如何通过首选项打开手机设置页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为一个应用程序设置一个页面,我想要的功能之一是让用户通过重定向到用户手机设置来通过设置页面更改权限。
我想弄清楚如何以编程方式执行该操作。我想知道是否可以通过如示例中所示的首选项以与 android.intent.action.VIEW
相同的方式完成操作,或者我是否有其他程序
I am making a settings page for an app and one of the features I want is for the user to change the permissions through the settings page by redirecting to the users phones settings.
I am trying to figured out how to do that programmatically. I am wondering if it can be done like the same way as android.intent.action.VIEW
through the preference like I show in the example or is there a different procedure I have to follow.
<Preference android:title="Example">
<intent android:action="android.intent.action.VIEW"
android:data="https://example.com/" />
</Preference>
推荐答案
您可以为此使用onSharedPreferenceChanged侦听器! p>
You can use onSharedPreferenceChanged Listener for this purpose !
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
// get the preference that has been changed
Preference selectedPreference= findPreference(key);
Object changedPreference = selectedPreference;
// Log.d("CHECK",selectedPreference.getTitle().toString());
// and if it's an instance of EditTextPreference class, update its summary
if (selectedPreference instanceof EditTextPreference) {
//Do your stuff
}
}
这篇关于如何通过首选项打开手机设置页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文