0

I want to show only wi-fi settings fragment from settings. I have achieved this by using following code:

        Intent i = new Intent(Settings.ACTION_SETTINGS);
        i.putExtra(":android:show_fragment", "com.android.settings.wifi.WifiSettings");
        i.putExtra(":android:no_headers", true);
        startActivity(i);

Now I want to show only date & time fragment from settings so I changed my code to:

        Intent i = new Intent(Settings.ACTION_SETTINGS);
        i.putExtra(":android:show_fragment","com.android.settings.ACTION_DATE_SETTINGS");
        i.putExtra(":android:no_headers", true); 
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);

unfortunately it's not working.How can I display only specific Settings fragment from android inbuilt Settings app like this

Rahul Matte
  • 1,151
  • 2
  • 23
  • 54

2 Answers2

1

I want to show only wi-fi settings fragment from settings. I have achieved this by using following code:

I would recommend that you use ACTION_WIFI_SETTINGS and get rid of the undocumented extras.

Now I want to show only date & time fragment from settings so I changed my code... unfortunately it's not working.

The right solution is to use ACTION_DATE_SETTINGS and get rid of the undocumented extras. Beyond that, com.android.settings.ACTION_DATE_SETTINGS is not the name of a fragment.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • thanks for response...you are correct the solution which you have suggested shows other settings options which I don't want – Rahul Matte Jul 07 '14 at 11:41
  • 1
    @RahulMatte: Your solution assumes a particular implementation of the Settings app. Device manufacturers are more likely to have implemented support for these specialized actions. They are welcome to change fragment class names as they wish, and many manufacturers have done so. Hence, your solution will crash or otherwise misbehave on some Android devices. – CommonsWare Jul 07 '14 at 11:45
0

Evidently no_headers was silently removed from Android L and above... so we are out of luck. Re-write just select pieces of com.android.settings and block the standard settings through MDM - then pray for SYSTEM signature on your app.

Nimantha
  • 6,405
  • 6
  • 28
  • 69