Search code examples
androidandroid-intentandroid-wifiwifi-direct

Intent to open Wi-Fi Direct settings


To open the WI-FI settings the code is:

startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));

To open the WI-FI Direct settings the code is ?


Solution

  • Here's the manifest for that activity on KitKat,

        <activity android:name="Settings$WifiP2pSettingsActivity"
                android:taskAffinity="com.android.settings"
                android:parentActivityName="Settings$WifiSettingsActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.VOICE_LAUNCH" />
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                android:value="com.android.settings.wifi.p2p.WifiP2pSettings" />
            <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                android:resource="@id/wireless_settings" />
        </activity>
    

    So it doesn't look like they exposed an explicit intent. You may be able to start it via ComponentName but the name is not guaranteed to be the same across Android releases.