Example usage for android.view SurfaceHolder setKeepScreenOn

List of usage examples for android.view SurfaceHolder setKeepScreenOn

Introduction

In this page you can find the example usage for android.view SurfaceHolder setKeepScreenOn.

Prototype

public void setKeepScreenOn(boolean screenOn);

Source Link

Document

Enable or disable option to keep the screen turned on while this surface is displayed.

Usage

From source file:com.intel.xdk.display.Display.java

@JavascriptInterface
public void startAR() {
    arView = CameraPreview.newInstance(activity.getApplicationContext());
    arView.setVisibility(View.INVISIBLE);

    arView.height = 100;//from   w w  w . j a  v  a  2s  .co m
    arView.width = 100;

    //no way to get current background color?
    arView.setBackgroundColor(Color.TRANSPARENT);

    SurfaceHolder sfhTrackHolder = arView.getHolder();
    sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);
    sfhTrackHolder.setKeepScreenOn(true);
    sfhTrackHolder.setFixedSize(100, 100);

    activity.runOnUiThread(new Runnable() {
        public void run() {

            //activity.addContentView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
            //activity.addContentView(arView, new LinearLayout.LayoutParams(400, 500, 0.0F));
            ViewGroup rootView = (ViewGroup) webView.getParent().getParent();
            rootView.addView(arView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.FILL_PARENT));
            rootView.bringChildToFront((View) webView.getParent());

            arView.setVisibility(View.VISIBLE);
            arView.showCamera();
            webView.bringToFront();
            webView.setBackgroundColor(0x00000000);
            LinearLayout ll = (LinearLayout) webView.getParent();
            ll.setBackgroundColor(0x00000000);

            View activityView = activity.getCurrentFocus();
        }
    });
}