Android Code Snippet SETTING

Hi all.
I tried it with Android > 6 to set to automatically open the settings window with the following code:

B4X:
    Dim i As Intent
    i.Initialize("", "")
    i.SetComponent("com.android.settings/.SecuritySettings")
    StartActivity(i)

as suggestion in a thread by NJDUDE ( LINK )

but this give me error:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 342)
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.SecuritySettings}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1854)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1545)
at android.app.Activity.startActivityForResult(Activity.java:4283)
at android.app.Activity.startActivityForResult(Activity.java:4230)
at android.app.Activity.startActivity(Activity.java:4567)
at android.app.Activity.startActivity(Activity.java:4535)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:698)
at b4a.example.main._activity_create(main.java:342)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Anyway i found solution with this code:

B4X:
Dim StartIntent As Intent
StartIntent.Initialize("android.settings.USAGE_ACCESS_SETTINGS", "")
StartActivity(StartIntent)

if you read this documentation ( LINK )
you can add Setting as you want:

ACTION_ACCESSIBILITY_SETTINGS
Activity Action: Show settings for accessibility modules.
** ACTION_ADD_ACCOUNT
Activity Action: Show add account screen for creating a new account.
** ACTION_AIRPLANE_MODE_SETTINGS
Activity Action: Show settings to allow entering/exiting airplane mode.
** ACTION_APN_SETTINGS
Activity Action: Show settings to allow configuration of APNs.
** ACTION_APPLICATION_DETAILS_SETTINGS
Activity Action: Show screen of details about a particular application.
** ACTION_APPLICATION_DEVELOPMENT_SETTINGS
Activity Action: Show settings to allow configuration of application development-related settings.
** ACTION_APPLICATION_SETTINGS
Activity Action: Show settings to allow configuration of application-related settings.
** ACTION_BATTERY_SAVER_SETTINGS
Activity Action: Show battery saver settings.
** ACTION_BLUETOOTH_SETTINGS
Activity Action: Show settings to allow configuration of Bluetooth.
** ACTION_CAPTIONING_SETTINGS
Activity Action: Show settings for video captioning.
** ACTION_CAST_SETTINGS
Activity Action: Show settings to allow configuration of cast endpoints.
** ACTION_DATA_ROAMING_SETTINGS
Activity Action: Show settings for selection of 2G/3G.
** ACTION_DATE_SETTINGS
Activity Action: Show settings to allow configuration of date and time.
** ACTION_DEVICE_INFO_SETTINGS
Activity Action: Show general device information settings (serial number, software version, phone number, etc.).
** ACTION_DISPLAY_SETTINGS
Activity Action: Show settings to allow configuration of display.
** ACTION_DREAM_SETTINGS
Activity Action: Show Daydream settings.
** ACTION_HARD_KEYBOARD_SETTINGS
Activity Action: Show settings to configure the hardware keyboard.
** ACTION_HOME_SETTINGS
Activity Action: Show Home selection settings.
** ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS
Activity Action: Show screen for controlling background data restrictions for a particular application.
** ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS
Activity Action: Show screen for controlling which apps can ignore battery optimizations.
** ACTION_INPUT_METHOD_SETTINGS
Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods.
** ACTION_INPUT_METHOD_SUBTYPE_SETTINGS
Activity Action: Show settings to enable/disable input method subtypes.
** ACTION_INTERNAL_STORAGE_SETTINGS
Activity Action: Show settings for internal storage.
** ACTION_LOCALE_SETTINGS
Activity Action: Show settings to allow configuration of locale.
** ACTION_LOCATION_SOURCE_SETTINGS
Activity Action: Show settings to allow configuration of current location sources.
** ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS
Activity Action: Show settings to manage all applications.
** ACTION_MANAGE_APPLICATIONS_SETTINGS
Activity Action: Show settings to manage installed applications.
** ACTION_MANAGE_DEFAULT_APPS_SETTINGS
Activity Action: Show Default apps settings.
** ACTION_MANAGE_OVERLAY_PERMISSION
Activity Action: Show screen for controlling which apps can draw on top of other apps.
** ACTION_MANAGE_WRITE_SETTINGS
Activity Action: Show screen for controlling which apps are allowed to write/modify system settings.
** ACTION_MEMORY_CARD_SETTINGS
Activity Action: Show settings for memory card storage.
** ACTION_NETWORK_OPERATOR_SETTINGS
Activity Action: Show settings for selecting the network operator.
** ACTION_NFCSHARING_SETTINGS
Activity Action: Show NFC Sharing settings.
** ACTION_NFC_PAYMENT_SETTINGS
Activity Action: Show NFC Tap & Pay settings

This shows UI that allows the user to configure Tap&Pay settings.
** ACTION_NFC_SETTINGS
Activity Action: Show NFC settings.
** ACTION_NOTIFICATION_LISTENER_SETTINGS
Activity Action: Show Notification listener settings.
** ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS
Activity Action: Show Do Not Disturb access settings.
** ACTION_PRINT_SETTINGS
Activity Action: Show the top level print settings.
** ACTION_PRIVACY_SETTINGS
Activity Action: Show settings to allow configuration of privacy options.
** ACTION_QUICK_LAUNCH_SETTINGS
Activity Action: Show settings to allow configuration of quick launch shortcuts.
** ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
Activity Action: Ask the user to allow an app to ignore battery optimizations (that is, put them on the whitelist of apps shown by ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS).
** ACTION_SEARCH_SETTINGS
Activity Action: Show settings for global search.
** ACTION_SECURITY_SETTINGS
Activity Action: Show settings to allow configuration of security and location privacy.
** ACTION_SETTINGS
Activity Action: Show system settings.
** ACTION_SHOW_REGULATORY_INFO
Activity Action: Show the regulatory information screen for the device.
** ACTION_SOUND_SETTINGS
Activity Action: Show settings to allow configuration of sound and volume.
** ACTION_SYNC_SETTINGS
Activity Action: Show settings to allow configuration of sync settings.
** ACTION_USAGE_ACCESS_SETTINGS
Activity Action: Show settings to control access to usage information.
** ACTION_USER_DICTIONARY_SETTINGS
Activity Action: Show settings to manage the user input dictionary.
** ACTION_VOICE_CONTROL_AIRPLANE_MODE
Activity Action: Modify Airplane mode settings using a voice command.
** ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE
Activity Action: Modify Battery Saver mode setting using a voice command.
** ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE
Activity Action: Modify do not disturb mode settings.
** ACTION_VOICE_INPUT_SETTINGS
Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods.
** ACTION_VPN_SETTINGS
Activity Action: Show settings to allow configuration of VPN.
** ACTION_VR_LISTENER_SETTINGS
Activity Action: Show VR listener settings.
** ACTION_WEBVIEW_SETTINGS
Activity Action: Allows user to select current webview implementation.
** ACTION_WIFI_IP_SETTINGS
Activity Action: Show settings to allow configuration of a static IP address for Wi-Fi.
** ACTION_WIFI_SETTINGS
Activity Action: Show settings to allow configuration of Wi-Fi.
** ACTION_WIRELESS_SETTINGS
Activity Action: Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks.
** AUTHORITY
** EXTRA_ACCOUNT_TYPES
Activity Extra: Limit available options in launched activity based on the given account types.
** EXTRA_AIRPLANE_MODE_ENABLED
Activity Extra: Enable or disable Airplane Mode.
** EXTRA_AUTHORITIES
Activity Extra: Limit available options in launched activity based on the given authority.
** EXTRA_BATTERY_SAVER_MODE_ENABLED
Activity Extra: Enable or disable Battery saver mode.
** EXTRA_DO_NOT_DISTURB_MODE_ENABLED
Activity Extra: Enable or disable Do Not Disturb mode.
** EXTRA_DO_NOT_DISTURB_MODE_MINUTES
Activity Extra: How many minutes to enable do not disturb mode for.
** EXTRA_INPUT_METHOD_ID
** INTENT_CATEGORY_USAGE_ACCESS_CONFIG
Activity Category: Show application settings related to usage access.
** METADATA_USAGE_ACCESS_REASON
Metadata key: Reason for needing usage access.

Bye
Marco
 

MarcoRome

Expert
Licensed User
Longtime User
When i try your code i got this excpetion:

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
~w:1004,main,46
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Ignoring event: ciaone_ready
** Activity (main) Resume **
main_position_checkedchange (B4A line: 102)
StartActivity(StartIntent)
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.ACTION_LOCATION_SOURCE_SETTINGS flg=0x20000 }
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1878)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1545)
    at android.app.Activity.startActivityForResult(Activity.java:4283)
    at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
    at android.app.Activity.startActivityForResult(Activity.java:4230)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
    at android.app.Activity.startActivity(Activity.java:4567)
    at android.app.Activity.startActivity(Activity.java:4535)
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:698)
    at b4a.example.FAB.main._position_checkedchange(main.java:958)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.objects.CompoundButtonWrapper$1.onCheckedChanged(CompoundButtonWrapper.java:44)
    at android.widget.CompoundButton.setChecked(CompoundButton.java)
    at android.support.v7.widget.SwitchCompat.setChecked(SwitchCompat.java:1061)
    at android.support.v7.widget.SwitchCompat.toggle(SwitchCompat.java:1056)
    at android.widget.CompoundButton.performClick(CompoundButton.java)
    at android.view.View$PerformClick.run(View.java)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7229)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
Without ACTION_ look my example in post #1
 

MarcoRome

Expert
Licensed User
Longtime User
upload_2016-10-28_22-23-48.png
 
Top