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

  • <tfoot id='UJucm'></tfoot>

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

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

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

        無法在android api23上打開位置?

        Can#39;t turn on location on android api23?(無法在android api23上打開位置?)

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

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

            1. <tfoot id='GJatJ'></tfoot>

                  <tbody id='GJatJ'></tbody>
              1. <legend id='GJatJ'><style id='GJatJ'><dir id='GJatJ'><q id='GJatJ'></q></dir></style></legend>
                  <bdo id='GJatJ'></bdo><ul id='GJatJ'></ul>
                • 本文介紹了無法在android api23上打開位置?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我使用了以下代碼,請求許可的對話框按預期顯示.但是當我單擊允許"時,它什么也不做.日志消息似乎沒有被授予權限,所以我去我的參數來驗證位置是否打開"并且它是關閉".它不應該是因為我授予應用程序訪問我的位置的權限嗎?如果我手動將其打開"然后再次運行該應用程序,一旦它請求我的許可,它就會工作并顯示日志消息,但并不是請求權限(通過對話)打開位置(當它關閉)如果用戶點擊允許"?難道我做錯了什么 ?我應該提到我正在 api23 上運行應用程序

                  I have used the following code and the dialogue that asks for permission shows as expected. But when I click "allow" it doesn't do anything. The log message doesn't appear as if the permission wasn't granted so I went to my parameters to verify if location is "on" and it was "off". Wasn't it supposed to be on because I granted the app access to my location ? If I manually turn it "on" and then run the app again, once it asks for my permission, it works and shows the log message but isn't the whole point of asking for permissions (via dialogue) to turn on location (when it's off) if the user clicks "allow" ? Am I doing something wrong ? I should mention that I'm running the app on api23

                  是我的Oncreate中的代碼:

                   mApiClient = new GoogleApiClient.Builder(this)
                                  .addConnectionCallbacks(this)
                                  .addOnConnectionFailedListener(this)
                                  .addApi(LocationServices.API)
                                  .build();
                  
                   mApiClient.connect();
                  
                      // Create the LocationRequest object
                          mLocationRequest = LocationRequest.create()
                                  .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                                  .setInterval(10 * 1000)        // 10 seconds, in milliseconds
                                  .setFastestInterval(1 * 1000); // 1 second, in milliseconds
                  

                  這是我的 OnConnected 方法:

                      public void onConnected(@Nullable Bundle bundle) {
                              //start the service
                  //checking and asking for permission
                  
                              if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                                  if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                                      ActivityCompat.requestPermissions(this,
                                              new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                                              MY_PERMISSION_ACCESS_FINE_LOCATION);
                                  }
                                  //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                                  //                                          int[] grantResults)
                                  // to handle the case where the user grants the permission. See the documentation
                                  // for ActivityCompat#requestPermissions for more details.
                                  return;
                              }
                              Location location = LocationServices.FusedLocationApi.getLastLocation(mApiClient);
                  
                              if (location == null) {
                                  LocationServices.FusedLocationApi.requestLocationUpdates(mApiClient, mLocationRequest, this);
                  
                              } else {
                                  //If everything went fine lets get latitude and longitude
                                  currentLatitude = location.getLatitude();
                                  currentLongitude = location.getLongitude();
                                  Log.v("currentLatitude",currentLatitude + " WORKS " + currentLongitude + "");
                              }
                  
                      }
                  

                  推薦答案

                  試試這個代碼:

                  private LocationCoord gps = null;
                  private static final int PERMISSION_REQUEST_CODE = 1;
                  

                  在 OnCreate() 中:

                  In OnCreate():

                  //GPS Manage
                      LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                      boolean gps_enabled = false;
                      boolean network_enabled = false;
                  
                      try {
                          gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
                      } catch (Exception ex) {
                      }
                  
                      try {
                          network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
                      } catch (Exception ex) {
                      }
                  
                      if (!gps_enabled && !network_enabled) {
                          // notify user
                          AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                          dialog.setMessage("Allow ImHere to access this device's location?");
                          dialog.setPositiveButton("Allow", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                                  // TODO Auto-generated method stub
                                  Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                  startActivity(myIntent);
                                  //get gps
                              }
                          });
                          dialog.setNegativeButton("Deny", new DialogInterface.OnClickListener() {
                  
                              @Override
                              public void onClick(DialogInterface paramDialogInterface, int paramInt) {
                                  // TODO Auto-generated method stub
                  
                              }
                          });
                          dialog.show();
                      }
                  
                      gps = new LocationCoord(this);
                  

                  <小時>

                  @Override
                  protected void onStart() {
                      super.onStart();
                  
                      // permission android 6.0
                      if (!checkPermission()) {
                          requestPermission();
                      }
                  
                  }
                  
                  
                  private boolean checkPermission(){
                      int result = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
                      if (result == PackageManager.PERMISSION_GRANTED) return true;
                      else return false;
                  }
                  
                  private void requestPermission(){
                      ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_REQUEST_CODE);
                  }
                  

                  您將需要 Manifest.xml 的此權限:

                  You will need this permissions on the Manifest.xml:

                  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
                  <uses-permission android:name="android.permission.INTERNET" />
                  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
                  

                  你可以在這里獲取 LoocationCord.java:https://github.com/toomyy94/ImHere-Chatbot/blob/master/app/src/main/java/pt/ua/tomasr/imhere/modules/LocationCoord.java

                  You can get LoocationCord.java here: https://github.com/toomyy94/ImHere-Chatbot/blob/master/app/src/main/java/pt/ua/tomasr/imhere/modules/LocationCoord.java

                  這篇關于無法在android api23上打開位置?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 或網絡提供商)
                  <tfoot id='sAilM'></tfoot><legend id='sAilM'><style id='sAilM'><dir id='sAilM'><q id='sAilM'></q></dir></style></legend>

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

                          <bdo id='sAilM'></bdo><ul id='sAilM'></ul>
                            <i id='sAilM'><tr id='sAilM'><dt id='sAilM'><q id='sAilM'><span id='sAilM'><b id='sAilM'><form id='sAilM'><ins id='sAilM'></ins><ul id='sAilM'></ul><sub id='sAilM'></sub></form><legend id='sAilM'></legend><bdo id='sAilM'><pre id='sAilM'><center id='sAilM'></center></pre></bdo></b><th id='sAilM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sAilM'><tfoot id='sAilM'></tfoot><dl id='sAilM'><fieldset id='sAilM'></fieldset></dl></div>
                              <tbody id='sAilM'></tbody>
                            主站蜘蛛池模板: 在线久草| 波多野结衣中文字幕一区二区三区 | 国产亚洲精品精品国产亚洲综合 | 久久精品国产免费一区二区三区 | 一级黄色毛片a | 成人欧美一区二区 | 夜夜爽99久久国产综合精品女不卡 | 精品在线| 精品一区二区三区不卡 | 成人午夜免费在线视频 | 免费看国产一级特黄aaaa大片 | 黄免费观看| 精品国产一区二区三区免费 | 91偷拍精品一区二区三区 | 久久精品黄色 | 日韩精品免费视频 | 欧美成人精品一区二区男人看 | 久久精品99国产精品 | 一a一片一级一片啪啪 | 99re6在线视频精品免费 | 国产乱码精品一区二区三区忘忧草 | 日韩欧美精品 | 国产69久久精品成人看动漫 | 亚洲精品福利视频 | 日韩视频在线播放 | 国产视频一区二区 | 91社区在线观看 | 香蕉久久av| 天天人人精品 | 一区二区三区视频 | 亚洲a一区二区 | 午夜影院在线免费观看视频 | 亚洲三区视频 | 日韩精品一区二区三区中文在线 | 国产免费自拍 | 一a级片 | 成人国产精品久久久 | 九九久久99 | 999久久| 久在线| 成人小视频在线观看 |