在我的情況下,我有一個應用程序,它是一個webview應用程序。 4.1或更高版本使用getUrl()將返回路徑。但是當我使用Android 4.0時,它將返回null。 我已經做了很多搜索這種情況。但找不到答案。 任何人都可以幫助我嗎?Android webview get url返回null
回答
「public String getUrl()
獲取當前頁面的URL,這並不總是與傳遞給WebViewClient.onPageStarted的URL相同,因爲儘管該URL的負載已經開始,但當前頁面可能沒有改變。 (c)Android Developers
因此,如果您的頁面尚未加載,那麼getUrl將返回null。嘗試在您的自定義WebViewClient中的onPageFinished中調用它,以進行檢查。
我已經使用它之前它是在4.1 - 4.4之間的工作。但是當我使用只是不工作的4.0設備。 – user2357288 2014-11-04 02:20:42
@ user2357288我在HTC Sensation(4.0)上測試了它。一切正常。 – QArea 2014-11-04 09:56:57
我仍然無法解決問題。但我用另一種方法來處理這個問題。也許這將是簡單而靈活的。任何地方,感謝您的建議。 =] – user2357288 2015-02-14 02:42:15
- 1. Android的webview cookie返回null
- 2. android get activity返回null
- 3. Angular 2 HTTP GET返回URL null
- 4. Android WebView數據庫存儲返回null
- 5. findViewById爲WebView返回null
- 6. Cookie :: get()返回null
- 7. @ArquillianResource返回null URL
- 8. hibernate session get返回null
- 9. Morphia(MongoDB)Datastore「get」返回null
- 10. android intent.getAction()返回null
- 11. GET(URL)返回錯誤
- 12. CookieManager.getCookie()返回null
- 13. Android BaseAdapter:getTag()返回null
- 14. Android - GsonRequest返回null
- 15. Android BitmapFactory.decodeFile返回null
- 16. Android - MediaStore.Video.query()返回null
- 17. Android findFragmentById返回null
- 18. Android findViewById返回null
- 19. Android getParcelableExtra返回null
- 20. android getlastknownlocation返回null
- 21. Android - BitmapFactory.decodeByteArray返回null
- 22. Android ListView:getTag()返回NULL
- 23. android sharedpreferences返回null
- 24. Android,findViewById返回null
- 25. Android getAuthToken返回null
- 26. Android ProgressDialog返回null
- 27. BitmapFactory返回null Android
- 28. Android lastKnownLocation返回null
- 29. android BluetoothDevice.getName()返回null
- 30. Android bitmap.getwidth返回null?
發佈您正在使用的代碼。 – Salem 2014-11-03 10:18:58
寫更多的代碼,你試試什麼和錯誤? – 2014-11-03 10:40:27