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

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

      <legend id='4OZNN'><style id='4OZNN'><dir id='4OZNN'><q id='4OZNN'></q></dir></style></legend>

        <small id='4OZNN'></small><noframes id='4OZNN'>

      1. 無法在 Android 的瀏覽器上使用 Javascript 獲取 GPS

        Unable to get GPS coordinates using Javascript on browser in Android(無法在 Android 的瀏覽器上使用 Javascript 獲取 GPS 坐標)

          <bdo id='hUp6y'></bdo><ul id='hUp6y'></ul>

              <legend id='hUp6y'><style id='hUp6y'><dir id='hUp6y'><q id='hUp6y'></q></dir></style></legend>

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

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

                  <tbody id='hUp6y'></tbody>
                1. 本文介紹了無法在 Android 的瀏覽器上使用 Javascript 獲取 GPS 坐標的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對 android、java 和 javascript 編碼非常陌生.

                  I am very new to android, java and javascript coding.

                  我正在嘗試獲取當前的 GPS 坐標,然后在 Android 設備上對其進行跟蹤.我正在使用 webview,并且大部分代碼都是用 javascript 編寫的.

                  I am trying to get current GPS co-ordinates and track it thereafter on an Android device. I am using webview and the majority of the code is written in javascript.

                  這幾天我進行了很多搜索并嘗試了許多不同的方法,但我無法在 android 設備上獲取 GPS 坐標.請查看代碼并幫助我弄清楚為什么我沒有獲得 GPS 位置.

                  I have searched a lot for a few days and tried many different ways but I am unable to get GPS co-ordinates on the android device. Please have a look at the code and hel pme figure out why I am not getting the GPS location.

                  需要指出的幾點是 -1. 我下載并檢查了其他傳感器應用程序,可以看到當前顯示的 GPS 坐標(因此 GPS 正在設備上工作).2. 當我運行我的代碼時,我在通知區域看到 GPS 搜索圖標,它一直在閃爍,但從未修復.3. 當我在筆記本電腦瀏覽器上只運行帶有 javascript 的 HTML 文件時,它會請求共享位置的權限,然后給出坐標,但是同一個文件在 android 中沒有顯示任何內容.

                  A few things to point are - 1. I downloaded and checked other sensor apps and can see the current GPS co-ordinates being shown (so the GPS is working on the device). 2. When I run my code, I see the GPS searching icon in the notification area, it keeps blinking but never fixes. 3. When I run only the HTML file with the javascript on a laptop browser, it ask permission to share location and then it gives the co-ordinates, however the same file does not show anything in android.

                  請查看下面的代碼并幫助我解決這個問題.我已經嘗試了很多,并將其發布為我最后的希望.

                  Please have a look at the code below and help me figure this out. I have tried a lot and am posting this as my last hope.

                  清單文件具有以下權限-

                  The manifest file has the following permissions -

                  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
                  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
                  <uses-permission android:name="android.permission.INTERNET"/>
                  <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" />
                  

                  Android中的主要java代碼有-

                  The main java code in Android has -

                  @Override
                  public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      webView = new WebView(this);  
                      webView.getSettings().setJavaScriptEnabled(true);   
                      webView.getSettings().setLoadWithOverviewMode(true);
                      webView.getSettings().setUseWideViewPort(true);
                      webView.loadUrl("file:///android_asset/mymap.html");
                      setContentView(webView);
                  }
                  

                  而帶有 javascript 的 HTML 文件是 -

                  And the HTML file with the javascript is -

                  <!DOCTYPE html>
                  <html>
                  <body onunload="OnUnload()" onload="getLocation()">
                  <p id="demo">Your coordinates:</p>
                  <script>
                  var watchID;
                  var x=document.getElementById("demo");
                  function getLocation()
                    {
                    if (navigator.geolocation)
                      {
                         var options = {maximumAge:600000, timeout:100000, enableHighAccuracy: true};
                         watchID = navigator.geolocation.watchPosition(showPosition,showError,options);
                      }
                    else{x.innerHTML="Geolocation is not supported by this browser.";}
                    }
                  function showPosition(position)
                    {
                    x.innerHTML="Latitude: " + position.coords.latitude + 
                    "<br />Longitude: " + position.coords.longitude;  
                    }
                  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;
                      }
                    }
                  
                  function OnUnload()
                  {
                     alert ("The current document will be unloaded!");
                     navigator.geolocation.clearWatch(watchID);
                  }  
                  </script>
                  </body>
                  </html>
                  

                  提前非常感謝,斧頭

                  推薦答案

                  好吧,我做了進一步的搜索并找到了解決方案.我在此處發布這些鏈接,作為對我的問題的回答,供任何前來這里尋找答案的人使用.

                  Well I did further search and found a solution. I am posting these links here as answer to my question for anyone who comes till here looking for answers.

                  在加載 url 之前,我必須在我的 java 代碼中添加這些行,然后我才能看到地理坐標.

                  I had to add these lines in my java code before loading the url and then I was able to see the geo-coordinates.

                      webView.getSettings().setGeolocationEnabled(true);
                      webView.setWebChromeClient(new WebChromeClient() {
                           public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
                              // callback.invoke(String origin, boolean allow, boolean remember);              
                              callback.invoke(origin, true, false);
                           }
                          });
                  

                  更多信息請點擊這兩個鏈接-

                  For more information follow these two links -

                  • android webview 地理位置
                  • Android:使用 html5 確定地理位置在 webview 中使用 javascript api

                  這篇關于無法在 Android 的瀏覽器上使用 Javascript 獲取 GPS 坐標的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                2. <small id='CprJP'></small><noframes id='CprJP'>

                    <tbody id='CprJP'></tbody>

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

                        <tfoot id='CprJP'></tfoot>
                            <bdo id='CprJP'></bdo><ul id='CprJP'></ul>
                            主站蜘蛛池模板: 淫片一级国产 | 欧美精品二区三区 | 久久久久成人精品免费播放动漫 | 特黄色一级毛片 | 在线视频中文字幕 | 久久久久久毛片免费观看 | 亚洲中午字幕 | 亚洲天堂中文字幕 | av片在线观看网站 | 欧美www在线| 精品国产乱码久久久久久中文 | 久久久91| 日韩欧美三级电影 | 九九精品视频在线 | 一级片在线播放 | 亚洲精品国产成人 | 欧美精品电影一区 | 亚洲欧美综合精品另类天天更新 | 国产精品久久九九 | 欧美精品一二区 | 国产无套一区二区三区久久 | 精品亚洲一区二区 | 亚洲欧美视频一区 | 国产黄色麻豆视频 | 欧美日韩精品一区二区三区四区 | 高清一区二区 | 日本黄视频在线观看 | 久久精品 | 麻豆久久久| 国产精品毛片无码 | 男人的天堂avav | 亚洲免费一区 | 精品国产精品三级精品av网址 | 欧美乱人伦视频 | 91视频亚洲 | 亚洲欧美在线观看 | 天天综合网天天综合色 | 一区二区在线视频 | 国产精品久久久精品 | 久久精品一级 | 精久久|