I tried to enable the geolocation service for the webview, but it never asks for it. I then enabled the service via settings, and it times out every time I try to use it. Is there any problem?
Here’s my code in MainActivity.java:
package com.example.quickweather;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.*;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView daApp = (WebView)findViewById(R.id.DaApp);
WebSettings props = daApp.getSettings();
props.setJavaScriptCanOpenWindowsAutomatically(true);
props.setJavaScriptEnabled(true);
props.setGeolocationEnabled(true);
props.setAllowFileAccessFromFileURLs(true);
props.setAllowFileAccess(true);
props.setAppCacheEnabled(true);
props.setDatabaseEnabled(true);
props.setDomStorageEnabled(true);
props.setAllowContentAccess(true);
daApp.setWebChromeClient(new WebChromeClient(){
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback){
callback.invoke(origin,true,false);
}
});
daApp.loadUrl("file:///android_asset/webinterface/index.html");
}
}