Hello,
Due to problems with RingtoneManagerWrapper.class and amazon, and to not have 2 Phone libraries (Phone2 without this class).
I'm trying to replace PhoneWakeState.class, from Phone library, with this code:
It works well, and the screen stays on.
If I put the app in the background, the screen turns off and when I return to bring to the fore, the screen stays on. Perfect.
But if I rotate the device then no longer useful, because when rotate, the screen turns off.
This is the solution I found:
I declare javaObject in Globals and initialize in activity_create
Works perfectly, even when i rotate the device, but is correct?
Thanks
Due to problems with RingtoneManagerWrapper.class and amazon, and to not have 2 Phone libraries (Phone2 without this class).
I'm trying to replace PhoneWakeState.class, from Phone library, with this code:
B4X:
Sub Process_Globals
Private nm As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
nm.InitializeContext
End If
nm.RunMethod("wake",Null)
End Sub
#If JAVA
import android.view.WindowManager;
import android.view.View;
import android.view.Display;
public void wake() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Display display = getWindowManager().getDefaultDisplay();
View view = getWindow().getDecorView().findViewById(android.R.id.content);
if (view != null){
view.setKeepScreenOn(true);
}
}
#End If
It works well, and the screen stays on.
If I put the app in the background, the screen turns off and when I return to bring to the fore, the screen stays on. Perfect.
But if I rotate the device then no longer useful, because when rotate, the screen turns off.
This is the solution I found:
I declare javaObject in Globals and initialize in activity_create
B4X:
Sub Globals
Dim nm As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
End If
nm.InitializeContext
nm.RunMethod("wake",Null)
End Sub
Works perfectly, even when i rotate the device, but is correct?
Thanks