Open specific Settings-page programmatically

2019-07-13 16:36发布

问题:

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)

回答1:

ACTION_SECURITY_SETTINGS Intent:

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

For complete Settings Intents



回答2:

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);