Page 144 - MDP2022-2
P. 144
public class camera extends AppCompatActivity {
private WebView mWebView;
private WebSettings mWebSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWebView = findViewById(R.id.webView);
setContentView(R.layout.activity_camera);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.setWebViewClient(new WebViewClient());
mWebSettings = mWebView.getSettings();
mWebSettings.setJavaScriptEnabled(true);
mWebSettings.setSupportMultipleWindows(true);
mWebSettings.setJavaScriptCanOpenWindowsAutomatically(false);
mWebSettings.setLoadWithOverviewMode(true);
mWebSettings.setUseWideViewPort(true);
mWebSettings.setSupportZoom(false);
mWebSettings.setBuiltInZoomControls(false);
mWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
mWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
mWebSettings.setDomStorageEnabled(true);
mWebView.loadUrl("http://192.168.0.31:8000/?action=stream");
mWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
finish();
return false;
}
});
}
}
카메라 화면(xml)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/
res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".camera">
<WebView
android:id="@+id/webView"