久久久久久久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>
                            主站蜘蛛池模板: 国产高清视频在线观看播放 | 91国在线| 亚洲一区二区在线播放 | 另类a v| 日韩在线观看一区二区三区 | 国产激情视频网站 | 国偷自产av一区二区三区 | 国产日韩欧美在线 | 国产一级免费视频 | 欧美另类视频在线 | 亚洲视频精品 | 欧美一级片免费看 | 亚洲精品久久视频 | 视频一区二区三区中文字幕 | 欧美成人一区二免费视频软件 | 日日夜夜精品 | 久久精品国产99国产精品 | 作爱视频免费看 | 国产一区二区在线播放视频 | 欧美国产精品久久久 | 日本黄色激情视频 | 久久久久久亚洲国产精品 | 日韩一区二区福利 | 91在线一区 | 日韩精品在线看 | 黄色毛片在线播放 | 天堂一区二区三区四区 | 国产偷录视频叫床高潮对白 | 国产一区二区影院 | h视频免费观看 | 精品亚洲一区二区三区 | 亚洲综合区 | av网站免费看 | 一区二区三区四区电影 | 欧美日韩成人在线 | 国产精品成人一区二区三区 | 亚洲欧美日韩高清 | 日韩精品一区二区三区在线观看 | 亚洲啊v在线 | 日韩欧美一区二区三区免费观看 | 日韩视频区 |