2012-04-24 23 views
0

我有一個WebView加載頁面的基於位置功能和WebChromeClient與onGeolocationPermissionsShowPrompt()重寫。啓用位置服務時,啓用頁面的位置可以正常工作。WebChromeClient.onGeolocationPermissionsShowPrompt()從未調用過,如果位置關閉

問題是,如果用戶的位置關閉,我想提示他們打開它,但如果它關閉,我從來沒有打過GeolocationPermissionsShowPrompt()。只有位置可用時纔會調用此功能嗎?

回答

0

不知道這是你在尋找什麼,但我只是調用一個方法CheckEnableGPS()

//Method for turning GPS on if it isn't 
    private void CheckEnableGPS(){  
    String provider = Settings.Secure.getString(getContentResolver(),  
    Settings.Secure.LOCATION_PROVIDERS_ALLOWED);  
    if(!provider.equals("")) 
    {   
     //GPS Enabled   
    Toast.makeText(ShowMapActivity.this, "GPS Enabled: " + provider,   Toast.LENGTH_LONG).show();  
    } 
    else 
    {   
    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);   startActivity(intent);  
     } 
    } 
+0

我有這樣的一個方法,這個問題是我要運行的方法當webview中的頁面請求當前位置,但WebChromeClient只有在位置已經打開的情況下才會從頁面獲取請求,這會破壞檢測它的目的。不過謝謝。 – dwemthy 2012-04-24 20:18:57

+0

你也有webView.getSettings()。setGeolocationEnabled(true)? – 2012-04-24 21:30:03

相關問題