Saturday, 17 February 2018

Keeping the Device Awake Android ( Keep Screen On )

2 Ways  , We can Keep the screen On .


1 . XML
2. Coding


Via Xml  :

In the root of your layout xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true">
    ...</LinearLayout>
Coding :

public class MyActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }

Happy Coding . I appreciate your feedback .

1 comment:

  1. It is a very informative and useful post thanks it is good material to read this post increases my knowledge. Advanced PHP Tutorial

    ReplyDelete