Reputation: 1018
What code would you use to prevent the Droid from locking on an app? I am writing an app that uses sockets, and it is essential that the screen not lock in the middle of the app's execution.
Upvotes: 0
Views: 414
Reputation: 395
Turn Off Screen Lock by adding the following against the Activity in your AndroidManifest.xml
android:keepScreenOn="true"
The screen will remain on and be cautious of using this as the display being kept on could impact your battery usage in you Application.
Upvotes: 1
Reputation: 1226
I'm not entirely sure what you mean. But I took it to be an unresponsive UI. So if that assumption is correct threading is your answer, do your socket work in here so the UI does not "lock-up"
new Thread(new Runnable(){
@Override
public void run(){
Code Here ....
}
}).start();
Keep in mind also that if you have strange exceptions about modifying UI elements from this thread the Looper can sometimes be useful. http://developer.android.com/reference/android/os/Looper.html
Upvotes: 0