12

For example, how do I launch User Settings? It's not implemented as its own Activity, so I'm not sure how to start it.

Below are some other similar questions but these are either more general or more specific. My question is about starting an arbitrary SubSettings fragment.

How do I call a specific PreferenceFragment from a PreferenceActivity?

Show only wireless system settings on Android 3

2 Answers 2

10

You can launch most Android Settings sub-screens by starting the SubSettings Activity and including the :android:show_fragment extra with the appropriate fully-qualified class name of an existing Android PreferenceFragment subclass.

For example, to start UserSettings:

adb shell am start -n com.android.settings/com.android.settings.SubSettings -e :android:show_fragment com.android.settings.users.UserSettings

To start DeviceInfoSettings:

adb shell am start -n com.android.settings/com.android.settings.SubSettings -e :android:show_fragment com.android.settings.DeviceInfoSettings

These examples use 'adb shell am start', but in principle you could invoke these in Java code (EDIT: Unfortunately you need to be signed with the system key, otherwise you get a SecurityException). Notice that the key for this extra has a colon at the front of it. To find other Settings, checkout the Android source and look for subclasses of PreferenceFragment in the packages/apps/Settings.

The situation was different in Froyo and before. In those days Activities were used to implement Settings sub-screens, so one could launch directly into a sub-screen (for example SoundAndDisplaySettings) by the usual method of calling startActivity() with a ComponentName or action String. This mechanism still works for some Settings sub-screens. For example, to bring up a wifi picker, you can use

adb shell am start -a android.net.wifi.PICK_WIFI_NETWORK
10
  • Do you know perhaps how to reach the new "Process Stats" screen, which is reachable via the "developers options", starting from Kitkat ? May 21, 2014 at 5:14
  • 1
    It doesn't work. It shows "java.lang.SecurityException: Permission Denial: starting Intent". Also, how did you get it? May 21, 2014 at 7:36
  • 2
    But I used ADB too, via the command line. About how to find it, in which file/s did you look at? May 21, 2014 at 13:28
  • 1
    To start a SubSettings fragment from Java code, use: startActivity(new Intent().setComponent(new ComponentName("com.android.settings","com.android.settings.SubSettings")).putExtra(":android:show_fragment", "com.android.settings.DeviceInfoSettings")); (replace DeviceInfoSettings with whatever you are interested in).
    – Jo Jo
    Jul 4, 2014 at 2:06
  • 3
    Has anyone figured out how to do this for Lollipop?
    – darkrat
    Nov 12, 2014 at 23:12
3

for MM :

am start -n com.android.settings/com.android.settings.SubSettings -e :settings:show_fragment com.android.settings.applications.RunningServices

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.