1

I got problems with Android WebView and my webpage. The page is ok in my Chrome Browser, but stays empty in the Android webview (Internet Permission granted, but no additional Permissions granted in the Manifest). Do you have any hints for me? The other answers don't seem to apply here. Normally I would use Googles Map View Control in Android, but in that case I really have to use a WebView. And I'm really bad at JavaScript :-(

my Javascript looks like this:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="https://maps.google.com/maps/api/js?v=3.exp">
</script>
<script>
if (navigator.geolocation) {
            alert("Geolocation IS supported.");
    navigator.geolocation.getCurrentPosition(showCurrentLocation);
} else {
    alert("Geolocation API not supported.");
}

function showCurrentLocation(position) {
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var coords = new google.maps.LatLng(latitude, longitude);

    var mapOptions = {
        zoom : 15,
        center : coords,
        mapTypeControl : true,
        mapTypeId : google.maps.MapTypeId.ROADMAP
    };

    //create the map, and place it in the HTML map div
    map = new google.maps.Map(document.getElementById("mapPlaceholder"),
            mapOptions);

    //place the initial marker
    var marker = new google.maps.Marker({
        position : coords,
        map : map,
        title : "Current location!"
    });
}
</script>



</head>
<style>
mapPlaceholder {
height: 400px;
width: 700px;
background-color: graytext;
}
</style>
    <body>
    <div>
        <div id="mapPlaceholder"></div>
    </div>
</body>
</html>

and the Android Code:

            WebView wvTask = (WebView) findViewById(R.id.wvTask);
            wvTask.getSettings().setJavaScriptEnabled(true);
            wvTask.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
            wvTask.getSettings().setLoadWithOverviewMode(true);
            wvTask.getSettings().setUseWideViewPort(true);
            wvTask.getSettings().setBuiltInZoomControls(true);
            wvTask.getSettings().setPluginState(WebSettings.PluginState.ON);
            wvTask.getSettings().setGeolocationEnabled(true);
            wvTask.getSettings().setLoadsImagesAutomatically(true);
            wvTask.setWebChromeClient(new WebChromeClient());
            wvTask.getSettings().setDomStorageEnabled(true);
            wvTask.getSettings().setAppCacheEnabled(true);
            wvTask.getSettings().setDatabaseEnabled(true);
            wvTask.loadUrl(XXX); //here is my URL, tried both https and http - nothing worked. 
robeppef
  • 11
  • 3

0 Answers0