We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Good afternoon,
I need to keep alive the screen while running the app I'm designing:
I found this code that should work: http://stackoverflow.com/questions/2131948/force-screen-on
import android.os.Bundle;
import android.view.WindowManager;
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
the compiler gives me this error:
5. ERROR in C:\Users\Processing\AppData\Local\Temp\android6000073045011166850sketch\src\processing\test\siacer_actualizable_60and\Siacer_actualizable_60AND.java (at line 6469)
protected void onCreate(Bundle icicle) {
^^^^^^^^^^^^^^^^^^^^^^^
Cannot reduce the visibility of the inherited method from PApplet
What I can do?
A greeting and thanks advance
Comments
Good evening, I have found other solution to my problem In Android 4.4 KitKat.
The app sometimes not start, I changed load images from setup to draw and has been fixed.
Have you declared wake lock permission in your Manifest? if not, declare it as:
<uses-permission android:name="android.permission.WAKE_LOCK" />
I am also using wake lock to keep screen on in my game.@anthony20 I have a question, does your app loads normally when you press the lock button of device or your app calls "onStop()" by any mean? My game does not work when it calls "onStop()" and then gets focus. What could be the problem?
If I press lock button while my game is in foreground then it calls onStop() and immediately onDestroy() and when I open the lock only white screen is displayed with background music of the game. But if I press home button when my game is in foreground and then press the lock button it only calls onStop() method. And if I unlock the device and resume my game it runs from where left. What could be the problem if you can help me?
Hello @Khubaib, I have the same problem with my app. What I've done is go keeping relevant information to charge during the Reset of the app.
Hi @anthony20, I also did that and stored the values in shared preference in a function of the game and called that function in onPause() of the activity. It is storing and retrieving correct values but the problem is that when the lock button is pressed while the game is in foreground the orientation changes from landscape (my game's default) to portrait. When I unlock the screen, because the device is in portrait mode, the game takes values as for a portrait orientation and my objects are misplaced from their correct positions. I am using Box2D for physics. What can I do?
Hi @Khubaib, I do this:
I not use onPause(). Does this work on your game?