Hi all. The code below works fine on a lot (tenth) of devices. It shows the settings panel to prompt the user to exclude the app from the Android battery optimization. If GetAndroidApiLevel>=23 Then Dim JavaObject1 As JavaObject JavaObject1.InitializeContext Dim...
I saw this example before post this thread but it do not work for me. I want to know if battery saver mode is on or off, and do not want to avoid my app to be stopped from S.O.
I work with GPS and when the Battery Saver Mode is on, the GPS do not work properly
I am also facing the same issue.... when battery saver is ON, GPS and other foreground services [MQTT] is stopped. Even firebase services is not working.
I saw this example before post this thread but it do not work for me. I want to know if battery saver mode is on or off, and do not want to avoid my app to be stopped from S.O.
I work with GPS and when the Battery Saver Mode is on, the GPS do not work properly
Sub Activity_Create(FirstTime As Boolean)
'Activity.LoadLayout("Layout")
Dim JavaObject1 As JavaObject
JavaObject1.InitializeContext
Dim risultato As Boolean = JavaObject1.RunMethod("isPowerSaveMode", Null)
If risultato = True Then
Log("PoweSaveMode is TRUE")
Else
Log("PoweSaveMode is False")
End If
End Sub
#If JAVA
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.provider.Settings;
import android.net.Uri;
import anywheresoftware.b4a.BA;
public boolean isPowerSaveMode(){
Context context = this;
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return pm.isPowerSaveMode();
}
#End If
I think you don't read. I said that the code MUST BE CHANGED. And just one example to get you on the right track.
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Activity.LoadLayout("Layout")
Dim JavaObject1 As JavaObject
JavaObject1.InitializeContext
Dim risultato As Boolean = JavaObject1.RunMethod("isPowerSaveMode", Null)
If risultato = True Then
Log("PoweSaveMode is TRUE")
Else
Log("PoweSaveMode is False")
End If
End Sub
#If JAVA
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.provider.Settings;
import android.net.Uri;
import anywheresoftware.b4a.BA;
public boolean isPowerSaveMode(){
Context context = this;
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return pm.isPowerSaveMode();
}
#End If