久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='283vI'><style id='283vI'><dir id='283vI'><q id='283vI'></q></dir></style></legend>

  • <i id='283vI'><tr id='283vI'><dt id='283vI'><q id='283vI'><span id='283vI'><b id='283vI'><form id='283vI'><ins id='283vI'></ins><ul id='283vI'></ul><sub id='283vI'></sub></form><legend id='283vI'></legend><bdo id='283vI'><pre id='283vI'><center id='283vI'></center></pre></bdo></b><th id='283vI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='283vI'><tfoot id='283vI'></tfoot><dl id='283vI'><fieldset id='283vI'></fieldset></dl></div>

        <bdo id='283vI'></bdo><ul id='283vI'></ul>
      <tfoot id='283vI'></tfoot>
      1. <small id='283vI'></small><noframes id='283vI'>

      2. Android webview 地理定位數據庫無法打開

        Android webview geoposition database failed to open(Android webview 地理定位數據庫無法打開)

          <i id='ssVYI'><tr id='ssVYI'><dt id='ssVYI'><q id='ssVYI'><span id='ssVYI'><b id='ssVYI'><form id='ssVYI'><ins id='ssVYI'></ins><ul id='ssVYI'></ul><sub id='ssVYI'></sub></form><legend id='ssVYI'></legend><bdo id='ssVYI'><pre id='ssVYI'><center id='ssVYI'></center></pre></bdo></b><th id='ssVYI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ssVYI'><tfoot id='ssVYI'></tfoot><dl id='ssVYI'><fieldset id='ssVYI'></fieldset></dl></div>
            <bdo id='ssVYI'></bdo><ul id='ssVYI'></ul>
            1. <legend id='ssVYI'><style id='ssVYI'><dir id='ssVYI'><q id='ssVYI'></q></dir></style></legend>

              <small id='ssVYI'></small><noframes id='ssVYI'>

                <tfoot id='ssVYI'></tfoot>
                  <tbody id='ssVYI'></tbody>

                  本文介紹了Android webview 地理定位數據庫無法打開的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個使用 javascript geolocation api 的網站,并希望它在 web 視圖中打開.我在清單文件中設置了這些權限:

                  I have website using javascript geolocation api and want it to open in a webview. I set up these permissions in the manifest file:

                  <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"/>
                  

                  在我的活動中,我還設置了 webview 設置:

                  In my activity, I also set webview settings:

                  webview.getSettings().setDatabaseEnabled(true);
                  webview.getSettings().setDomStorageEnabled(true);
                  webview.getSettings().setGeolocationDatabasePath("/data/data/com.my.app/databases");
                  webview.getSettings().setGeolocationEnabled(true);
                  

                  我還處理了 javascript 地理定位對話框:

                  And I also handled javascript geolocation dialog:

                  webview.setWebChromeClient(new WebChromeClient(){
                      @Override
                      public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
                          callback.invoke(origin, true, false);
                      }
                  });
                  

                  地理位置本身正在工作,但我無法將地理位置緩存到數據庫中.它應該在 CachedGeoposition.db 中自行完成,但是當我啟動 webview 時,我得到了這個奇怪的 SQLite 錯誤:

                  Geolocation itself is working, but I am not able to cache geoposition into the database. It should be doing it by itself into CachedGeoposition.db, but when I start the webview, i get this strange SQLite error:

                  E/SQLiteLog(22653): (14) cannot open file at line 30174 of [00bb9c9ce4]
                  E/SQLiteLog(22653): (14) os_unix.c:30174: (2) open(/CachedGeoposition.db) -
                  D/WebKit  (22653): ERROR:
                  D/WebKit  (22653): SQLite database failed to load from /CachedGeoposition.db
                  D/WebKit  (22653): Cause - unable to open database file
                  D/WebKit  (22653):
                  D/WebKit  (22653): external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cp
                  p(71) : bool WebCore::SQLiteDatabase::open(const WTF::String&, bool)
                  

                  當我在文件資源管理器中檢查 CachedGeoposition.db 文件是否存在時,它總是在那里,db的權限設置為-rw------.

                  When I check existence of CachedGeoposition.db file in File Explorer, it is always there, and permissions of the db are set to -rw-------.

                  我是否在設置中遺漏了一些可能導致數據庫無法正確打開的內容?我是 Android 新手,現在正在嘗試尋找 2 天的解決方案.任何幫助將不勝感激.謝謝.

                  Did I miss something in settings what could cause database not to open correctly? I'm new to Android and trying to find solution for 2 days now. Any help would be greatly appreciated. Thank you.

                  推薦答案

                  我將發布一個對我有用的解決方案,希望它可以提供一些關于錯誤可能在哪里的想法.如果您可以提供有關您正在測試的設備(模擬器)/操作系統的詳細信息,這也會有所幫助.

                  I'll post a solution that worked for me in the hope that it might provide some ideas on where the error might be. It would also help if you could provide details about the device(emulator)/os on which you're testing.

                  我測試過(沒有錯誤):

                  I tested on (with no errors):

                  • (模擬器)Galaxy Nexus (2.3.3)(創建數據/數據/package.name/files/CachedGeoposition.db 文件)
                  • (模擬器)Galaxy Nexus (3.0)(創建數據/data/package.name/files/CachedGeoposition.db 文件)
                  • HTC One S (4.1.1)(data/data/package.name/files/CachedGeoposition.db 文件已創建)
                  • Galaxy S3 (4.3)(看不到文件,因為我的手機沒有 root 并且在 4.3 上有一些運行方式"錯誤)
                  • Nexus 7 (4.4.4) - KIT KAT 上方的 webview 發生了一些變化,并且文件不再存在,但沒有顯示錯誤(即使提供了錯誤的數據庫"文件夾路徑)
                  • (模擬器)Galaxy S4 (5.0)(與 4.4.4 相同)

                  AndroidManifest 權限(差不多):

                  AndroidManifest permissions (pretty much the same):

                  <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"/>
                  

                  網頁視圖設置:

                  WebSettings webSettings = webview.getSettings();
                  webSettings.setJavaScriptEnabled(true);
                  webSettings.setDatabaseEnabled(true);
                  webSettings.setDomStorageEnabled(true);
                  webSettings.setGeolocationDatabasePath(getFilesDir().getPath());
                  webSettings.setGeolocationEnabled(true);
                  

                  Web chrome 客戶端(同):

                  Web chrome client (the same):

                  webview.setWebChromeClient(new WebChromeClient(){
                      @Override
                      public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
                          callback.invoke(origin, true, false);
                      }
                  });
                  

                  獲取地理位置的測試 html 文件:

                  Test html file for getting the geolocation:

                  <!DOCTYPE html>
                  <html>
                  <head>
                  <script>
                  var x = document.getElementById("demo");
                  
                  function getLocation() {
                      if (navigator.geolocation) {
                          navigator.geolocation.getCurrentPosition(showPosition, showError);
                      } else {
                          x.innerHTML = "Geolocation is not supported by this browser.";
                      }
                  }
                  
                  function showPosition(position) {
                      var latlon = position.coords.latitude + "," + position.coords.longitude;
                      document.getElementById("locationHolder").innerHTML = latlon;
                  }
                  
                  function showError(error) {
                      switch(error.code) {
                          case error.PERMISSION_DENIED:
                              x.innerHTML = "User denied the request for Geolocation.";
                              break;
                          case error.POSITION_UNAVAILABLE:
                              x.innerHTML = "Location information is unavailable";
                              break;
                          case error.TIMEOUT:
                              x.innerHTML = "The request to get user location timed out.";
                              break;
                          case error.UNKNOWN_ERROR:
                              x.innerHTML = "An unknown error occurred.";
                              break;
                      }
                  }
                  </script>
                  </head>
                  
                  <body>
                  
                  <p id="demo">Click the button to get your position.</p>
                  
                  <div id="locationHolder">No location</div>
                  <button onclick="getLocation()">Get position</button>
                  
                  </body>
                  </html>
                  

                  此外,對于本地測試,您可以在/assets/www/index.html"下創建一個包含 html 的文件,并使用以下代碼將其加載到 webview 中:

                  Also, for a local test, you could created a file containing the html under '/assets/www/index.html' and use the following code to load it into the webview:

                  try {
                      String html = readAssetFile("www/index.html");
                      webview.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
                  } catch (IOException e) {
                  }
                  

                  讀取資產文件方法:

                  private String readAssetFile(String filePath) throws IOException {
                      StringBuilder buffer = new StringBuilder();
                      InputStream fileInputStream = getAssets().open(filePath);
                      BufferedReader bufferReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"));
                      String str;
                  
                      while ((str=bufferReader.readLine()) != null) {
                          buffer.append(str);
                      }
                      fileInputStream.close();
                  
                      return buffer.toString();
                  }
                  

                  如果不提供數據庫"文件夾的錯誤硬編碼路徑,我無法重現您的錯誤.

                  I couldn't reproduce your error without providing a wrong hardcoded path to the 'databases' folder.

                  這篇關于Android webview 地理定位數據庫無法打開的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                  <small id='N25PI'></small><noframes id='N25PI'>

                  <i id='N25PI'><tr id='N25PI'><dt id='N25PI'><q id='N25PI'><span id='N25PI'><b id='N25PI'><form id='N25PI'><ins id='N25PI'></ins><ul id='N25PI'></ul><sub id='N25PI'></sub></form><legend id='N25PI'></legend><bdo id='N25PI'><pre id='N25PI'><center id='N25PI'></center></pre></bdo></b><th id='N25PI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='N25PI'><tfoot id='N25PI'></tfoot><dl id='N25PI'><fieldset id='N25PI'></fieldset></dl></div>

                        <tbody id='N25PI'></tbody>
                        <tfoot id='N25PI'></tfoot>

                        • <bdo id='N25PI'></bdo><ul id='N25PI'></ul>
                            <legend id='N25PI'><style id='N25PI'><dir id='N25PI'><q id='N25PI'></q></dir></style></legend>

                          • 主站蜘蛛池模板: 免费在线观看成人 | 日韩欧美一级精品久久 | 日韩中文视频 | 亚洲人成免费 | 99国产精品视频免费观看一公开 | 国产日韩欧美91 | 亚洲www啪成人一区二区 | 久久亚洲综合 | 亚洲欧洲精品成人久久奇米网 | 一区| 国产欧美精品区一区二区三区 | 国产一区二区三区四区hd | 狠狠干美女 | 精品久久伊人 | 噜啊噜在线 | 999国产视频 | 日韩国产一区二区三区 | 成人区一区二区三区 | 69视频在线播放 | 国产精品成人一区二区 | 久久精品av麻豆的观看方式 | 国产一区二区在线播放 | 伊人精品 | 99国产视频| 亚洲va在线va天堂va狼色在线 | www97影院 | 亚洲情视频| 精品国产久 | 999久久精品 | 亚洲一区免费视频 | 日韩精品成人 | 国产精品一区二区三区在线 | 在线观看黄色电影 | 91在线网站 | 91久久精品一区二区二区 | 色婷婷一区二区三区四区 | 一区二区三区视频在线 | 一区二区在线不卡 | 亚洲国产日本 | 国产一区久久久 | 中文字幕一区二区三区不卡 |