久久久久久久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 獲取位置或提示啟用位置服務

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

          <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 獲取位置或提示啟用位置服務的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在其他帖子中發現了這個答案的零碎,但我想在這里記錄下來以供其他人使用.

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

                  我怎樣才能簡單地請求用戶的 GPS 和/或網絡位置,并且如果他們尚未啟用該服務,則提示他們這樣做?

                  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?

                  推薦答案

                  如果您想在按鈕按下時捕獲位置,請按照以下步驟操作.如果用戶沒有啟用定位服務,這會將他們發送到設置菜單以啟用它.

                  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.

                  首先,您必須在清單中添加權限android.permission.ACCESS_COARSE_LOCATION".如果需要GPS(網絡定位不夠靈敏),添加權限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);
                          }
                      }
                  });
                  

                  我的外部班級設置了這個監聽器

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

                  然后,每當您想停止收聽時,請調用它.您至少應該在活動的 onStop 方法期間進行此調用.

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

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

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

                  相關文檔推薦

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

                      • <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>

                            主站蜘蛛池模板: 国产91久久久久久 | 理论片午午伦夜理片影院 | 人人做人人澡人人爽欧美 | 九九精品在线 | 粉嫩一区二区三区国产精品 | 国产二区三区 | 免费观看黄网站 | 五月天国产视频 | 欧美精品一区三区 | 日韩欧美一区二区三区免费观看 | 黄色片免费在线观看 | 午夜免费网站 | 日韩成人免费在线视频 | av免费网站在线 | 国产免费自拍 | 精品欧美色视频网站在线观看 | 日日干天天操 | 亚洲精品国产一区 | 中文字幕一级毛片视频 | 亚洲区一区二 | 亚洲精品久久久一区二区三区 | av中文字幕在线播放 | 国产日韩精品视频 | 国产精品视频在线观看 | 亚洲三级视频 | 神马久久久久久久久久 | 亚洲v日韩v综合v精品v | 日韩一区和二区 | 国产不卡在线 | 一区二区三区四区在线 | 天堂网中文字幕在线观看 | 欧美视频一区 | 久久成人免费 | caoporn视频在线 | 日本精品免费在线观看 | 91国产精品在线 | 精品日韩在线 | 免费一区二区三区 | 国产精品久久网 | 久草视频在线播放 | 亚洲精品视频一区 |