2

Android アプリに共有設定ファイルがあります。私の環境設定ファイル (xml) には、多数の CheckBoxPreferences があります。別の設定を追加して、ユーザーがそれを押すと、Android の位置設定 (gps) を取得できるようにします。

これを設定ファイルに追加しようとしました:

 <Preference xmlns:android="http://schemas.android.com/apk/res/android"
        android:key="pref_key_gpsStatus"
        android:title="Gps Settings" />

onPreferenceClick と onSharedPreferenceChanged でそれをキャッチして、意図的に gps 設定を呼び出すには:

startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));

設定をクリックしても何も起こりませんでした。

私が試した他のことはxmlファイルにあります:

<Preference xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="pref_key_gpsStatus"
    android:title="Gps Settings" />


    <intent 
        android:action="android.settings.WIRELESS_SETTINGS"/>

そして.. それでも何も起こりませんでした。

誰かがアイデアを持っていますか?

ありがとう!

これは完全な pref.xml ファイルです。

<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
    android:defaultValue="true"
    android:key="@string/pref_key_shakeSense"
    android:summaryOff="@string/shakeOff"
    android:summaryOn="@string/shakeOn"
    android:title="@string/shakeSence" />

<CheckBoxPreference
    android:defaultValue="true"
    android:key="@string/pref_key_locationViewShots"
    android:summaryOff="@string/displayOff"
    android:summaryOn="@string/displayOn"
    android:title="@string/locationViewShots" />

<CheckBoxPreference
    android:defaultValue="true"
    android:key="@string/pref_key_sound"
    android:summaryOff="@string/soundOff"
    android:summaryOn="@string/soundOn"
    android:title="@string/speakUserLocation" />

<CheckBoxPreference
    android:defaultValue="false"
    android:key="@string/pref_key_Zoom"
    android:summaryOff="@string/notActive"
    android:summaryOn="@string/active"
    android:title="@string/autoZoom" />

<Preference 
    android:key="pref_key_gpsStatus"
    android:title="Gps Settings" />
    <intent android:action="android.settings.WIRELESS_SETTINGS"/>
</PreferenceScreen>
4

1 に答える 1

0

このスニペットでは、意図は設定の外にあります。

<Preference xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="pref_key_gpsStatus"
    android:title="Gps Settings" />


<intent android:action="android.settings.WIRELESS_SETTINGS"/>

設定の一部としてそれを囲む必要があります。

<Preference xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="pref_key_gpsStatus"
    android:title="Gps Settings" >


    <intent android:action="android.settings.WIRELESS_SETTINGS"/>

</Preference>
于 2012-10-12T23:41:10.823 に答える