Android Question Lead the user to settings

Sgardy

Member
Licensed User
Longtime User
I need to lead the user to certain system setting when install my app, for example this:

B4X:
    Dim in1 As Intent
    in1.Initialize("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", "package:" & Application.PackageName)
    Dim JO As JavaObject
    in1.PutExtra("app_uid", JO.InitializeContext.RunMethodJO("getApplicationInfo", Null).GetField("uid"))
    in1.PutExtra("app_package", Application.PackageName)
    StartActivity(in1)

But nothing happen with this code, where I'm wrong? I tried also this:

B4X:
    Dim in1 As Intent
    in1.Initialize("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", "package:" & Application.PackageName)
    StartActivity(in1)

Same thing... It shows a blank setting page.

I know that the use of that setting is deprecated but my app use sensor in background and some phone, expecially Huawei, stop the working when in sleep mode.

Any suggestion? Thank you
 
Top