Is there a way to open the 'Smart Lock For Passwords' screen by code (ex. for opening GPS location by code we create a new intent with the following line:
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
Thanks,
Unfortunately, there is no way to programmatically trigger the settings activity via a public API, but we've put it on the feature request list, and I'll update this answer when it becomes available.
Related
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)
ACTION_SECURITY_SETTINGS Intent:
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);
For complete Settings Intents
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);
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).
I am using device default lock screen in my app for activating and deactivating screen lock. In my application I used a check box which shows that screen lock is activated or not.
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
I am receiving it callback in my DeviceAdminReceiver class.
Methods:onPasswordChanged onPasswordFailed onPasswordSucceeded
Now if user selects none or press back none of these methods get called. I am not able to identify is screen is locked or not ? I used OnActivityResult for handling callback in my Activity, it works fine for back pressed(resultcode 0) but gives same results for all other options.
I found this link which tells that it can't be handled externally.
Summary: I wants to handle screen lock options directly from my application.
if we set password quality on that case user can not able to select none password option
Might it will help you .
We can do this in this way
private ComponentName mDeviceAdmin;
private DevicePolicyManager mDPM;
mDPM.setPasswordQuality(mDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
mContext.startActivity(intent);
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
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.
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.
I am trying to help my users to turn on their GPS like this:
Intent gpsOptionsIntent = new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(gpsOptionsIntent);
The problem is that it opens the android settings as it was a view from my app, but I want to open it as a new application (android default settings aplication), in other words, outside my app.
Does anyone know how to accomplish what I want?
Thanks!
The code you are executing shows a new activity "on its own app process", if the activity you are calling is not in your application project it mean's that is not in your application context, so my thought is that just because you go back and fall down in the last activity shown you may think is in your app, but that's not the case, the activity is running on it's own process and because of the back stack you are going back to your previous activity.
Hope this Helps.
Regards!
The problem is that it opens the android settings as it was a view from my app,
No it doesn't. It's starting an Activity which is part of the Android Settings app.
but I want to open it as a new application (android default settings aplication), in other words, outside my app.
That's exactly what is happening - it's just opening the Activity which deals with the settings for Location Services rather than opening the default Settings root page.
Don't confuse the generic terms 'app' and 'application' with Android classes such as Application and Activity.
Android is meant to be modular - even though it looks like the Activity which is started with your code is part of your own 'app', in reality what happens is an instance of the native Settings app is created and the Location Services Activity is displayed. This happens entirely outside of your app.
As mentioned in this answer and comment, you need to add intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent gpsOptionsIntent = new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
// add the following line
gpsOptionsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(gpsOptionsIntent);
How to open Settings>About page programmaticlly in Android.
You can open it by simply using an Intent
Intent aboutPhone = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
startActivity(aboutPhone);
As in Android there are many Settings classes and here it would be :
android.provider.Settings
Looks like this is as close as you can get
Intent i = new Intent(Settings.ACTION_SETTINGS);
startActivity(i);
Takes you to the main settings page. There doesn't seem to be an option to go to the About Phone page.
Short answer you can't .
Long answer all you can do is create an activity and show all the info from about page in your activity by problematically polling out the info from the system