Create a abstract class BaseActivity
that calls in start()
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
then make all the activities in your app extend the BaseActivity
.
سؤال
Is there a way to force screen on at all activities of app. I don't wanna in just one activity, as in case of getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
, but one command to all activities.
المحلول
Create a abstract class BaseActivity
that calls in start()
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
then make all the activities in your app extend the BaseActivity
.
نصائح أخرى
You can use android:keepScreenOn
attribute in Views
. See http://developer.android.com/reference/android/view/View.html#attr_android:keepScreenOn