我正在制作一些需要用户选择地点的Android应用程序.我打算到用户谷歌的地方API.Link:https://developers.google.com/places/android/
通过Place Picker,这个API提供了很好的方法.https://developers.google.com/places/android/placepicker
现在假设我只想显示食物类型的用户地点(餐馆,酒店等).使用Places Browser API可以通过在请求中添加"type = restraunts"属性来完成.
有没有办法只使用Google Places Picker for android显示某些类型的地方?
android google-maps google-maps-api-3 android-location google-places-api
根据Android文档:
Google位置服务API是Google Play服务的一部分,它提供了一个功能更强大的高级框架,可自动处理位置提供程序,用户移动和位置准确性,而不是平台位置API
android.location.
但是使用融合位置提供程序(来自Google Play服务中的位置API)我不知道如何检查用户是否启用了位置或禁用了位置.
使用旧的 android.location很容易:
locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
Run Code Online (Sandbox Code Playgroud)
但我不想同时使用Google Play服务融合位置提供商和旧的 Android位置.
如何检查用户是否使用融合位置提供程序启用了该位置?
提前致谢.
android location android-location google-play-services fusedlocationproviderapi
我试图理解一个莫名其妙的情况 - 从2月15日开始,我们在应用程序中捕获的位置读数中非常高的百分比报告精确到10.0米的精度,这似乎与从GPS源到达的那些强烈相关,如我们所见它几乎完全采用高精度和仅传感器模式(尽管有电池节省的场合).
在审查了我们的系统之后,我们没有看到任何我们可以自己介绍它的地方.它会影响我们应用的所有已部署版本.
我们已经开始使用我们的应用程序来获取更多元数据,但是我们希望能够更好地理解这样的事情是如何在瞬间发生的,这会在我们没有更改任何正在运行的服务时影响应用程序的多个版本.
这里涉及一些与潜在相关的问题:
还有一些图表显示了我们所看到的内容:
那么 - 有没有其他人看过类似的东西,或者对这里发生的事情有所解释?
我正在使用以下代码来显示弹出窗口以打开位置
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequest);
SettingsClient client = LocationServices.getSettingsClient(getActivity());
Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build());
task.addOnSuccessListener(getActivity(), new OnSuccessListener<LocationSettingsResponse>() {
@Override
public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
// All location settings are satisfied. The client can initialize
// location requests here.
// ...
getUserLocation();
}
});
task.addOnFailureListener(getActivity(), new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
int statusCode = ((ApiException) e).getStatusCode();
Log.d("AMOD", "onFailure " + statusCode);
switch (statusCode) {
case CommonStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied, but this can be …Run Code Online (Sandbox Code Playgroud) android android-location android-support-library google-play-services onactivityresult
我无法在 SDK 29 中获得位置的“始终允许”提示。我已经在清单中设置了这些权限:
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Run Code Online (Sandbox Code Playgroud)
并请求用户在运行时允许这些权限。但它只返回“当应用程序打开时”和“拒绝”选项。
关于如何在 SDK 29 中显示它的任何想法。
我知道BroadcastReceiver会监视文本,电话事件等...但您可以将LocationServices作为基于位置的服务和事件运行吗?
例如,您靠近某个GPS点,手机会通知您.
我想做什么:
我正在尝试开发一个只需要用户在一个活动开始时的位置的应用程序.因此,只有当用户在活动中时,才能通过网络或GPS更新位置.因此,用户可以选择室内地图.
我的问题是什么:
但是,我发现应用程序始终使用历史记录位置,并且从不更新位置.我怀疑我的确有问题
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
但我不确定问题出在哪里.
相关代码片段:
在我Activity,我有:
locationDetector = new LocationDetector(MapSelectionActivity.this);
// try to get the current location
if (locationDetector.checkLocationServiceAvailability()) {
location = locationDetector.getLocation();
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
Log.d("MapSelectionActivity", latitude + " " + longitude);
//locationDetector.stopLocalization(); // stop the localization to save the energy
} else { // if no location service, requires the user to turn GPS on
locationDetector.showSettingsAlert();
}
Run Code Online (Sandbox Code Playgroud)
我的LocationDetector班级如下:
public final class …Run Code Online (Sandbox Code Playgroud) 嗨我需要在onchangelocation()上调用一个事件,通过比较当前纬度和经度与一些保存的纬度和经度,但我得到一个错误.日食不识别关键词距离,并且对于校正错误它给出提示箱子方法"距离"有4参数...如何解决它?或其他一些方式做同样的工作???
感谢致敬.代码附在下面
@Override
public void onLocationChanged(Location location) {
double currentLat=location.getLatitude();
double currentLon=location.getLongitude();
if (distance(lat,lon,currentLat,currentLon)<2.0){
//do what you want to do...
}
}
Run Code Online (Sandbox Code Playgroud) 为了获得用户当前位置,我使用过LocationManager:
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
Run Code Online (Sandbox Code Playgroud)
它易于阅读且代码非常简单.
但我注意到Google最近在Google Play服务中发布了新客户端API模型并建议使用FusedLocationProviderApi,它看起来更复杂,它是异步的,它需要处理回调等.
在LocationManager上使用FusedLocationProviderApi有什么好处吗?
android android-location google-play-services android-maps-utils
由于某种原因,最近更改了getMaxAddressLineIndex的实现.现在,此方法为第1行返回0.
我有一个现有的代码,曾经工作:) i<address.getMaxAddressLineIndex(.然而,它以某种方式被打破.
我不知道这是由于新的Google Api还是别的.
有人可以在这里确认一下发生了什么事吗?