Page 1 of 1

How to use Settings actions?

Posted: 09 Sep 2017 13:23
by Bluscre
I wonder how do i use stuff like https://stackoverflow.com/a/29739374
Do i have to use "Start Activity" or "Start Service" and what kind of syntax does it need?

Code: Select all

Settings.ACTION_ACCESSIBILITY_SETTINGS
doesn't work with either of these :(

Also trial 'n error'd some code

Code: Select all

settings = callJavaConstructor("android.provider.Settings", "Settings()");
ACTION_ACCESSIBILITY_SETTINGS = getJavaStaticField("android.provider.Settings", "ACTION_ACCESSIBILITY_SETTINGS");
//callJavaConstructor("android.content.Intent", "Intent(java.lang.Class)", ACTION_ACCESSIBILITY_SETTINGS);
intent = callJavaConstructor("android.content.Intent", "Intent()");
context = getContext();
callJavaMethod(intent, "android.content.Intent", "setClass(android.content.Context, java.lang.Class)", context, ACTION_ACCESSIBILITY_SETTINGS);
No success either ://

Re: How to use Settings actions?

Posted: 09 Sep 2017 14:01
by Bluscre
Finally i got it to work with

Code: Select all

context = getContext();
//settings = callJavaConstructor("android.provider.Settings", "Settings()");
ACTION_ACCESSIBILITY_SETTINGS = getJavaStaticField("android.provider.Settings", "ACTION_ACCESSIBILITY_SETTINGS");
//intent = callJavaConstructor("android.content.Intent", "Intent()");
intent = callJavaConstructor("android.content.Intent", "Intent(java.lang.String)", ACTION_ACCESSIBILITY_SETTINGS);
//FLAG_ACTIVITY_NEW_TASK = 
//callJavaMethod(intent, "android.content.Intent", "setAction(java.lang.String)", ACTION_ACCESSIBILITY_SETTINGS)
callJavaMethod(intent, "android.content.Intent", "addFlags(int)",  268435456);
callJavaMethod(context, "android.content.Context", "startActivity(android.content.Intent)", intent);

Re: How to use Settings actions?

Posted: 09 Sep 2017 15:16
by Martin
You could use action Launch Shortcut and build a settings shortcut. Probably not all screens are available using this method.
You can also use action Start Activity, check Explicit Component and select the com.android.settings and the suitable class in the second field.

Regards,
Martin

Re: How to use Settings actions?

Posted: 09 Sep 2017 16:18
by Desmanto
I usually use Launch App.
Package Name : com.android.settings
Class Name : com.android.settings.Settings$AccessibilitySettingsActivity

Try to execute it and it should land you directly on Accessibility. This feature is exactly like Autoshortcut.
(Other automation app after several years, still can't do this without autoshortcut plugin. :D Even such a simple feature, can't be integrated into the main app.)

To test the activity, I usually use quickshortcutmaker first. In automagic, if I need to find the correct class name, I have to select, try to execute it first. If wrong, I have rescroll back down so far to test the next class name (or tap search icon again). In quickshortcutmaker, the try button can be cancel and we are back at the list and can proceed to try the next class name.

This is also why I created the windows recognizer flow, to check the class name of the activity, so I can make a shortcut directly to it.