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)
Open specific Settings-page programmatically
Asked Answered
Possible duplicate of #19517917 See the android.provider.Settings Intents. –
Titania
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 :) –
Otoscope
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);
Can't accept my answer before 2 days time, but this is the correct one! –
Otoscope
ACTION_SECURITY_SETTINGS Intent:
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);
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);
Can't accept my answer before 2 days time, but this is the correct one! –
Otoscope
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).
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. –
Metalloid © 2022 - 2025 — McMap. All rights reserved.