久久久久久久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 坐標(biāo))

          <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 坐標(biāo)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

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

                  我正在嘗試獲取當(dāng)前的 GPS 坐標(biāo),然后在 Android 設(shè)備上對其進(jìn)行跟蹤.我正在使用 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.

                  這幾天我進(jìn)行了很多搜索并嘗試了許多不同的方法,但我無法在 android 設(shè)備上獲取 GPS 坐標(biāo).請查看代碼并幫助我弄清楚為什么我沒有獲得 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.

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

                  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.

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

                  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.

                  清單文件具有以下權(quán)限-

                  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>
                  

                  提前非常感謝,斧頭

                  推薦答案

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

                  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 代碼中添加這些行,然后我才能看到地理坐標(biāo).

                  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);
                           }
                          });
                  

                  更多信息請點(diǎn)擊這兩個鏈接-

                  For more information follow these two links -

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

                  這篇關(guān)于無法在 Android 的瀏覽器上使用 Javascript 獲取 GPS 坐標(biāo)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  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 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動期間獲取當(dāng)前位置)
                  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 | 在线不卡一区 | 2017天天干 | 国产一区在线播放 | 一级片免费观看 | 欧美精品久久久久久 | 五月天婷婷视频 | 国产精品久久久久久久久久久久久久久 | 日韩999| 青草久久久 | 蜜臀av性久久久久av蜜臀妖精 | 加勒比一区二区三区 | 亚洲一级黄色片 | 国产一区二区日韩 | 久久久婷婷 | 国产人妖在线 | 精品久久久久久久久久久 | 麻豆精品国产 | 日韩精品成人 | 亚洲欧美一区二区三区在线 | 黄色大片av | 亚洲精品一区二区三 | 曰本毛茸茸性生活 | 国产在线h | 久久国产综合 | 国产黄色免费视频 | 日本精品在线视频 | 最新超碰| 羞羞在线 | www.成人网 | 久久国产欧美 | 欧美色图一区二区 | 欧美一级在线观看 | 国产精品欧美精品 | 91中文在线 | 国产999在线观看 | 欧美成人精品一区二区三区在线看 | 中文字幕网站 | 国产成人综合网 | 国产一区二区不卡 |