How to startActivity to accessibility settings page of my app in Android - android

This question is quite similar to other.
However there is still no solution.
I am using the below code to jump to the accessibility settings page.
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(intent, REQUEST_USAGE_SETTING);
Instead of jump to main accessibility settings page, i would like to take the user to the settings page of my app.

for open setting page of your app you need to pass package name of your application as below,
try this it will redirect you to setting page of your application
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityForResult(intent, 1);

Related

Open my apps accessibility settings Page android

I want to open my apps accessibility settings on a press of a button Desired Page to Open(myApp)
Was only able to open accessibility settings accessibility Page
Tried adding data to Intent but got this error
"No Activity found to handle Intent
{act-android.settings.ACCESSIBILITY_SETTINGS dat=package:com.testapp4 fig=0x10000000 )"
Code:-
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
Uri uri=Uri.fromParts("package",getReactApplicationContext().getPackageName(),null);
intent.setData(uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getReactApplicationContext().startActivity(intent);

How to delete default Share App in Delphi code?

I am creating an Android Application in Delphi, and I need a Button, which deletes the default Share App, if one is set.
E.g
I share a File via Gmail, and press 'Always'
The next time, this is the default app.
Is it possible to delete this in Code? Or can i open the App-Infos where it is possible to reset this option?
clearPackagePreferredActivities() in PackageManager will clear the defaults of a particular app, whichever's package name you pass.
(https://stackoverflow.com/a/13072877/6517492)
You can open the application settings screen programmatically. Java code:
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
intent.setData(uri);
context.startActivity(intent);
(from https://stackoverflow.com/a/35456817/6517492)

How do I programmatically open energy saving settings in oppo device?

Hello I am trying to open energy savings settings of device oppo-CPH1609 for a specific application which looks like this.
Screenshot of settings screen.
I have tried following methods for doing it
Intent intent = new Intent();
intent.setAction(Settings.ACTION_BATTERY_SAVER_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
I have also tried to change action as
Settings.EXTRA_BATTERY_SAVER_MODE_ENABLED
Any Help would be appreciable.
You could do like below:
startActivityForResult(new Intent(android.provider.Settings.ACTION_BATTERY_SAVER_SETTINGS),0);
//0 is request code
And in onActivityResult method, you could handle returned result.

Open specific Settings-page programmatically

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

How to open the default android browser without specifying an URL?

I'm loosing my mind over this. I want to open the user's default web browser. I can use this:
startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("http://google.com")));
To open the browser and send the user to that URL. But I don't want to send him to a specific URL, I just want to open the browser. I'm sure it's a simple solution, I just can't find it. Any Ideas?
To just open the browser without any URL opened you can use
startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("about:blank")));
After a bunch of searching, I was able to do this:
PackageManager pm = getPackageManager();
Intent queryIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
ActivityInfo af = queryIntent.resolveActivityInfo(pm, 0);
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.setClassName(af.packageName, af.name);
startActivity(launchIntent);
It basically says "What application would handle this?". Then it grabs that applications package and class name then fires an intent for the main action.

Categories

Resources