Hi,
This works indeed at my site. Cannot try it at user site at this moment. I will try tomorrow.
I tried this and it is working fine (RestoreState is working) after manually kill the App.
But there is still a problem:
On my Samsung the App is killed after about 1 hour background and RestoreState is not working.
I did the same on my Motorolla Phone and it is working for 2 days without problem.
Both systems are on Android v11 and my App is the same version. On Android v10 there was no problem on both devices. RestoreState is working perfect.
There must something changed with the v11 Release of Samsung.
I know Samsung changed battery management.
I allready had this:
Sub CheckDoze
Dim p As Phone
If p.SdkVersion>=23 Then
Dim JavaObject1 As JavaObject
JavaObject1.InitializeContext
Dim Ignoring As Boolean=JavaObject1.RunMethod("isIgnoringBatteryOptimizations", Null)
If Ignoring=False Then
Dim JavaObject1 As JavaObject
JavaObject1.InitializeContext
JavaObject1.RunMethod("ShowPermissionDialog", Null)
End If
End If
#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 isIgnoringBatteryOptimizations(){
Context context=this;
String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return pm.isIgnoringBatteryOptimizations(packageName);
}
public void ShowPermissionDialog(){
Intent intent = new Intent();
Context context=this;
String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm.isIgnoringBatteryOptimizations(packageName)){
BA.LogInfo("isIgnoringBatteryOptimizations TRUE");
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
} else {
BA.LogInfo("isIgnoringBatteryOptimizations FALSE");
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
}
context.startActivity(intent);
}
#End If
End Sub
Mannually kill did disappear my App as selectable under the square button
Stopped by Samsung my App is still selectable, but no filled form. Starting empty as first start.
Questions:
1. Could it be dropped permissions after a while, so there is no access to the file system?
2. Could it be new battery management, but why is RestoreState not working on Resume?
3. Where would you start to investigate this because it is bound to Samsung? I try to read logs, but didnot succeed finding something.
4. Would B4XPages prevent/working better?
Kind regards,
André