【发布时间】:2016-07-11 04:30:52
【问题描述】:
我尝试使用 android studio 获取当前位置,但变量 currentLocation 始终为空值
和android studio在
下画红线 位置 currentLocation= LocationServices.FusedLocationApi.getLastLocation(mLocationclient);并要求检查权限 我尝试了两种检查权限和不检查的方法 但同样的结果返回空值
请问谁能帮帮我? 这是我使用的代码
私有 GoogleApiClient mLLocationclient; mLLocationclient=new GoogleApiClient.Builder(this) .addApi(LocationServices.API) .addConnectionCallbacks(这个) .addOnConnectionFailedListener(这个) 。建造(); mLLocationclient.connect(); 位置 currentLocation= LocationServices.FusedLocationApi.getLastLocation(mLocationclient); 如果(当前位置==空) Toast.makeText(this,"无法连接",Toast.LENGTH_SHORT).show(); 别的 { LatLng ll=新的 LatLng( currentLocation.getLatitude(), currentLocation.getLongitude() ); CameraUpdate 更新=CameraUpdateFactory.newLatLngZoom(ll,50); mMap.animateCamera(更新); }请帮帮我。
【问题讨论】:
-
android studio 在下画红线 -- 显示什么错误?
-
我认为这不是错误。但它只是请求检查权限
-
你能发布你的清单文件吗?
标签: android