2013-08-06 90 views
1

我試圖hablitar的GPS定位功能爲把這個清單中的android:如何在android webview中啓用GPS位置?

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_GPS" /> 
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" /> 
<uses-permission android:name="android.permission.ACCESS_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

,並把web視圖設置這樣的:

setGeolocationEnabled(true); 

,但仍然沒有工作。我應該怎麼做才能使它工作?我對此很陌生。

回答

2

您需要開始在代碼中請求GPS更新。

LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); 

LocationListener locationListener = new LocationListener() { 
    public void onLocationChanged(Location location) { 
           // Called when a new location is found by the location provider. 
    } 
} 
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1000, locationListener); 

然後你可以把你收到的GPS值,並通過他們通過URL喲web視圖

+0

我不明白的網址和代碼不會因爲第二行結束後工作是「(){」我得到錯誤 – Jaumesv

+0

當你使用webview時,你需要傳遞一個URL到它來顯示你想要查看的頁面。從你的問題,我假設你正試圖傳遞信息到頁面。 – TheHamstring

+0

請讓我知道,如果這解決了您的問題,並結束這個問題或提供的細節,如果沒有。 – TheHamstring