2016-11-23 22 views
0

我有一個目錄網站,當我使用移動網絡瀏覽器的地址鏈接在谷歌應用程序地圖很好地打開,然後當嘗試與我的webview應用程序相同時,它返回到谷歌地圖網站,所以它並不能解決我的位置....我想打開與谷歌地圖應用程序的鏈接...谷歌地圖應用程序的開放地址鏈接從一個webview應用程序

我試圖在Urlhander.java:(doesn't工作的代碼)

public static boolean map(Activity mActivity, String url) { 
    // When user clicks a hyperlink, load in the existing WebView 
    if(url.contains("http://maps.google.com/")) 
    { 
     Uri IntentUri = Uri.parse(url); 
     Intent mapIntent = new Intent(Intent.ACTION_VIEW, IntentUri); 
     mapIntent.setPackage("com.google.android.apps.maps"); 

     if (mapIntent.resolveActivity(mActivity.getPackageManager()) != null) { 
      mActivity.startActivity(mapIntent); 
     } 
     return true; 
    } 
    return false; 
} 
+0

你應該看看這個問題:http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android –

回答

0

嘗試使用片段從Adding a WebView to Your Application

WebView myWebView = (WebView) findViewById(R.id.webview); 
myWebView.loadUrl("http://www.example.com"); 

不要忘了包括互聯網權限:

< manifest ... > 
    <uses-permission android:name="android.permission.INTERNET" /> 
    ... 
</manifest> 

此使用WebView to access Google Maps指南也可能有幫助。

+0

謝謝我解決它。現在,當點擊地址鏈接時,它會打開地圖的本地應用程序,但是當我回去時,我的webview是空的。它沒有保存頁面。 –

相關問題