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

  • <legend id='o0fDa'><style id='o0fDa'><dir id='o0fDa'><q id='o0fDa'></q></dir></style></legend>

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

      <tfoot id='o0fDa'></tfoot>
      <i id='o0fDa'><tr id='o0fDa'><dt id='o0fDa'><q id='o0fDa'><span id='o0fDa'><b id='o0fDa'><form id='o0fDa'><ins id='o0fDa'></ins><ul id='o0fDa'></ul><sub id='o0fDa'></sub></form><legend id='o0fDa'></legend><bdo id='o0fDa'><pre id='o0fDa'><center id='o0fDa'></center></pre></bdo></b><th id='o0fDa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='o0fDa'><tfoot id='o0fDa'></tfoot><dl id='o0fDa'><fieldset id='o0fDa'></fieldset></dl></div>
        <bdo id='o0fDa'></bdo><ul id='o0fDa'></ul>
      1. 如果禁用,Android 獲取位置或提示啟用位置服務(wù)

        Android get location or prompt to enable location service if disabled(如果禁用,Android 獲取位置或提示啟用位置服務(wù))

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

            <tbody id='kSrc7'></tbody>
            <bdo id='kSrc7'></bdo><ul id='kSrc7'></ul>
          • <small id='kSrc7'></small><noframes id='kSrc7'>

          • <tfoot id='kSrc7'></tfoot>
            <legend id='kSrc7'><style id='kSrc7'><dir id='kSrc7'><q id='kSrc7'></q></dir></style></legend>

                  本文介紹了如果禁用,Android 獲取位置或提示啟用位置服務(wù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我在其他帖子中發(fā)現(xiàn)了這個(gè)答案的零碎,但我想在這里記錄下來(lái)以供其他人使用.

                  I've found bits and pieces of this answer scattered through other posts, but I wanted to record it here for others.

                  我怎樣才能簡(jiǎn)單地請(qǐng)求用戶的 GPS 和/或網(wǎng)絡(luò)位置,并且如果他們尚未啟用該服務(wù),則提示他們這樣做?

                  How can I simply request the user's GPS and/or Network location and, if they haven't enabled the service, prompt them to do so?

                  推薦答案

                  如果您想在按鈕按下時(shí)捕獲位置,請(qǐng)按照以下步驟操作.如果用戶沒(méi)有啟用定位服務(wù),這會(huì)將他們發(fā)送到設(shè)置菜單以啟用它.

                  If you want to capture the location on a button push, here's how you'd do it. If the user does not have a location service enabled, this will send them to the settings menu to enable it.

                  首先,您必須在清單中添加權(quán)限android.permission.ACCESS_COARSE_LOCATION".如果需要GPS(網(wǎng)絡(luò)定位不夠靈敏),添加權(quán)限android.permission.ACCESS_FINE_LOCATION",將Criteria.ACCURACY_COARSE"改為Criteria.ACCURACY_FINE"

                  First, you must add the permission "android.permission.ACCESS_COARSE_LOCATION" to your manifest. If you need GPS (network location isn't sensitive enough), add the permission "android.permission.ACCESS_FINE_LOCATION" instead, and change the "Criteria.ACCURACY_COARSE" to "Criteria.ACCURACY_FINE"

                  Button gpsButton = (Button)this.findViewById(R.id.buttonGPSLocation);
                  gpsButton.setOnClickListener(new OnClickListener() {
                  
                      @Override
                      public void onClick(View v) {
                          // Start loction service
                          LocationManager locationManager = (LocationManager)[OUTERCLASS].this.getSystemService(Context.LOCATION_SERVICE);
                  
                          Criteria locationCritera = new Criteria();
                          locationCritera.setAccuracy(Criteria.ACCURACY_COARSE);
                          locationCritera.setAltitudeRequired(false);
                          locationCritera.setBearingRequired(false);
                          locationCritera.setCostAllowed(true);
                          locationCritera.setPowerRequirement(Criteria.NO_REQUIREMENT);
                  
                          String providerName = locationManager.getBestProvider(locationCritera, true);
                  
                          if (providerName != null && locationManager.isProviderEnabled(providerName)) {
                              // Provider is enabled
                              locationManager.requestLocationUpdates(providerName, 20000, 100, [OUTERCLASS].this.locationListener);
                          } else {
                              // Provider not enabled, prompt user to enable it
                              Toast.makeText([OUTERCLASS].this, R.string.please_turn_on_gps, Toast.LENGTH_LONG).show();
                              Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                              [OUTERCLASS].this.startActivity(myIntent);
                          }
                      }
                  });
                  

                  我的外部班級(jí)設(shè)置了這個(gè)監(jiān)聽器

                  My outer class has this listener set up

                  private final LocationListener locationListener = new LocationListener() {
                  
                      @Override
                      public void onLocationChanged(Location location) {
                          [OUTERCLASS].this.gpsLocationReceived(location);
                      }
                  
                      @Override
                      public void onProviderDisabled(String provider) {}
                  
                      @Override
                      public void onProviderEnabled(String provider) {}
                  
                      @Override
                      public void onStatusChanged(String provider, int status, Bundle extras) {}
                  
                  };
                  

                  然后,每當(dāng)您想停止收聽時(shí),請(qǐng)調(diào)用它.您至少應(yīng)該在活動(dòng)的 onStop 方法期間進(jìn)行此調(diào)用.

                  Then, whenever you want to stop listening call this. You should at least make this call during your activity's onStop method.

                  LocationManager locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
                  locationManager.removeUpdates(this.locationListener);
                  

                  這篇關(guān)于如果禁用,Android 獲取位置或提示啟用位置服務(wù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經(jīng)度計(jì)算 X 和 Y)
                  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 有多可靠,多久更新一次?)
                  CLLocation returning negative speed(CLLocation 返回負(fù)速度)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測(cè)位置提供者?GPS 或網(wǎng)絡(luò)提供商)

                      • <bdo id='qXxcg'></bdo><ul id='qXxcg'></ul>

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

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

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

                            主站蜘蛛池模板: 99精品国产成人一区二区 | 精品亚洲一区二区 | 欧美精产国品一二三区 | 欧美女优在线观看 | 欧美日韩免费视频 | 婷婷狠狠 | 日韩午夜精品 | 国产视频久久久久 | 亚洲一区二区不卡在线观看 | 日韩国产精品一区二区三区 | 成人激情视频免费在线观看 | 91成人在线| 国产一区二区黑人欧美xxxx | 在线观看中文字幕视频 | 毛片一级黄色 | 国产日韩一区二区 | 狠狠操电影 | 人人人人人爽 | 国产精品久久a | 成人福利网| 久久久国产一区 | 中文字幕一区二区三区在线乱码 | 最新国产精品 | 国产激情一区二区三区 | 久久香蕉精品视频 | 国产精品国产a | 91一区二区三区在线观看 | 日本黄色高清视频 | 久久久视频在线 | 日日夜夜精品 | 欧美二区三区 | 久久精品国产亚洲一区二区三区 | 欧美久久免费观看 | 视频一区在线 | 人人干人人艹 | 亚洲欧美bt | 国产区视频在线观看 | 精品久久久久久18免费网站 | 在线观看免费av网 | 精品色| 国产欧美精品在线观看 |