I have a webview that opens the site with WebGl or CCS3D. On this site there is a button that includes a gyroscope.
If you access this site via chrome and click on this button, the gyroscope will turn on. If you run the site through a webview in the android app, then when you click on the gyroscope button, the site does not spin, as happens in chrome.
Question: how to turn on the gyroscope on android, so that when you click on the gyroscope button, the site is also spinning like in chrome?
The following permissions are enabled:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.VIBRATE"/> <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" /> <uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true" /> Code:
public class SecondActivity extends AppCompatActivity { WebView webView; final String ulr="http://sfer***.com/hodite/"; SensorManager sensorManager; Sensor sensor; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_second); webView=(WebView)findViewById(R.id.web); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setSupportZoom(true); webSettings.setDefaultTextEncodingName("utf-8"); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setAppCacheEnabled(true); webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); webSettings.setEnableSmoothTransition(true); //webView.setWebChromeClient(new WebChromeClient()); webView.loadUrl(ulr); /*sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);*/ }