7

Is there any way to, in my app, to redirect a user to a specific settings 'page'? My app works as a lock screen app, so I want to be able to redirect the user directly to the "Lock Screen" section of the Android settings. (Preferably via a button or something similar)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nyfiken Gul
  • 654
  • 4
  • 20
  • 1
    Possible duplicate of http://stackoverflow.com/questions/19517417/opening-android-settings-programmatically See the [android.provider.Settings Intents](https://developer.android.com/reference/android/provider/Settings.html). – GPuschka Aug 11 '16 at 07:07
  • Oh, didn't read the full thread - thanks mate, exactly what I need! Answer my question and i'll accept your answer if you want :) – Nyfiken Gul Aug 11 '16 at 07:11

3 Answers3

10

ACTION_SECURITY_SETTINGS Intent:

 Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
 startActivity(intent);

For complete Settings Intents

Nadeem Iqbal
  • 2,357
  • 1
  • 28
  • 43
7

I managed to find the correct answer in an old Stackoverflow-post from a while back. The code snippet now looks like this:

Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
Community
  • 1
  • 1
Nyfiken Gul
  • 654
  • 4
  • 20
1
val intent = Intent(Settings.ACTION_SECURITY_SETTINGS)
intent.flags =
    Intent.FLAG_ACTIVITY_NEW_TASK or
    Intent.FLAG_ACTIVITY_CLEAR_TOP

startActivity(intent)

Note the flags. These are optional, but necessary to remove the previous settings screen from the screen if it was previously open (this is needed if your application wants to open multiple settings screens).

Evgeny Zobnin
  • 11
  • 1
  • 1
  • Java: `intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)`. Docs: _This launch mode can also be used to good effect in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity of a task, it will bring any currently running instance of that task to the foreground, and then clear it to its root state._ – OneWorld Apr 14 '23 at 06:22