我在Android Studio中创建了Empty项目,并将网站转换为Android应用。当我在Chrome浏览器中打开网站时,一切正常,并且Google地图可见,但是在转换后的Android应用中,Google地图不可见。如何解决?
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebChromeClient;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.view.View;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
private WebView mywebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mywebView = (WebView)findViewById(R.id.webView);
WebSettings webSettings=mywebView.getSettings();
mywebView.loadUrl("https://mywebsite-Url");
webSettings.setJavaScriptEnabled(true);
mywebView.setWebViewClient(new WebViewClient());
}
答案 0 :(得分:-1)
WebView webview = (WebView) findViewById(R.id.webView1);
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://maps.google.com/maps?" + "saddr=43.0054446,-87.9678884" + "&daddr=42.9257104,-88.0508355");