启用与模式高精度或电池保存位置,而无需用户需要访问设置 [英] Enabling Location with mode High Accuracy or Battery saving without user needing to visit Settings

查看:221
本文介绍了启用与模式高精度或电池保存位置,而无需用户需要访问设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我问这个:(也尝试它在一个应用程序的原因)

Why i ask this:(also the reason for trying it in an app)

它发生当我们使用谷歌地图在棒棒堂即使位置被禁用,它是打开的,在高精度模式下用户的地图应用程序输入后,而不必访问设置。

我已经实现了类似的功能,启用蓝牙,凡在我的应用程序发起的行动;用户需要做出选择,但用户并不重定向设置,使用:

I have achieved a similar functionality for enabling Bluetooth, where the action is initiated in my app; user needs to make a choice but user is not redirected to Settings, using:

startActivity(新意图(BluetoothAdapter.ACTION_REQUEST_ENABLE));

这可能是在<一个发现href="http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#ACTION_REQUEST_ENABLE">BluetoothAdapter,现在我们知道有没有LocationAdapter,所以我环顾四周,<一个href="https://developer.android.com/reference/com/google/android/gms/location/LocationServices.html">gms->LocationServices,在<一个基本上几乎所有的东西href="https://developer.android.com/reference/com/google/android/gms/location/package-summary.html">Location API参考的,<一个href="https://developer.android.com/reference/android/location/LocationManager.html">android.location.LocationManager但似乎没有任何东西像 ACTION_REQUEST_ENABLE 可作为呢。

which could be found on BluetoothAdapter, now we know there is no LocationAdapter, so i looked around gms->LocationServices, basically almost everything under Location API references, android.location.LocationManager but doesn't seem anything like ACTION_REQUEST_ENABLE is available as yet.

希望有其他方法一样,而且越来越多的人尝试过。

Hope there is some other method for the same, and more people have tried it.

请注意:
context.startActivity(新意图(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); 不这样的。

Please note:
context.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); does not work like that.

推荐答案

更新2

UPDATE 2:

<一个href="https://github.com/googlesamples/android-play-location/tree/master/LocationSettings">GoogleSamples; LocationSettings - 为code基准

这个示例生成包含在这个Lo​​cationUpdates样本   回购,并允许用户来更新设备的位置设置   使用位置对话框。

This sample builds on the LocationUpdates sample included in this repo, and allows the user to update the device's location settings using a location dialog.

采用SettingsApi,保证了设备的系统设置   正确配置的应用程序的位置需要。

Uses the SettingsApi to ensure that the device's system settings are properly configured for the app's location needs.

更新1


UPDATE 1:

谷歌Play业务,7.0版发布(2015月)...

Google Play services, Version 7.0 (March 2015) released...

位置设置 - 尽管FusedLocationProviderApi结合多个传感器,让您的最佳位置,对精度   定位您的应用程序仍接收很大程度上取决于的设置   该装置(全球定位系统,无线网络,飞机模式,及其他)上启用。运用   新SettingsApi类,你可以把一个位置设置对话框   里面陈列着一触式控制,用户可以更改其设置   无需离开应用程序。

Location settings - While the FusedLocationProviderApi combines multiple sensors to give you the optimal location, the accuracy of the location your app receives still depends greatly on the settings enabled on the device (GPS, wifi, airplane mode, and others). Using the new SettingsApi class, you can bring up a Location Settings dialog which displays a one-touch control for users to change their settings without leaving your app.

使用的 <一个href="https://developer.android.com/reference/com/google/android/gms/location/SettingsApi.html">public接口SettingsApi

Using the public interface SettingsApi

      
  • 确定是否在设备上启用了相应的系统设置,进行所需的位置请求。
  •   
  • 另外,调用一个对话框,允许用户启用必要的位置设置有一个水龙头。
  •   

离开previous一部分,以供参考:
更新/应答
对于每个人都在寻找这个答案,谷歌播放服务7.0
它增加了API,用于检测的地方并连接到附近的设备,提高了对移动广告,健身数据,位置设置以及更多



Leaving the previous part for reference:
Update/Answer
For everybody looking for this answer, Google Play Services 7.0
It Adds APIs For Detecting Places And Connecting To Nearby Devices, Improves On Mobile Ads, Fitness Data, Location Settings, And More

在谷歌Play业务7.0,我们要介绍一个标准机制   检查是否启用了给定必要的位置设置   LocationRequest成功。如果有可能的改进,则   可以显示一个触摸控制让用户更改其设置   无需离开应用程序。

In Google Play services 7.0, we’re introducing a standard mechanism to check that the necessary location settings are enabled for a given LocationRequest to succeed. If there are possible improvements, you can display a one touch control for the user to change their settings without leaving your app.

该API提供了一个很好的机会,使一个更好的用户   经验,尤其是当位置信息是到临界   您的应用程序,如与谷歌地图时的情况下的用户体验   他们整合了位置设置对话框中,看到一个戏剧性   在一个良好的位置,状态,增加用户数量。

This API provides a great opportunity to make for a much better user experience, particularly if location information is critical to the user experience of your app such as was the case with Google Maps when they integrated the Location Settings dialog and saw a dramatic increase in the number of users in a good location state.

来源: <一个href="http://android-developers.blogspot.in/2015/03/google-play-services-70-places-everyone.html">Android开发者博客:谷歌Play业务7.0 - 放置每个人

SDK即将推出!
  我们将推出在谷歌Play业务7.0   接下来的几天。期待更新这个博客文章,出版   文档和SDK的可用性,一旦推出是   完成。

SDK Coming Soon!
We will be rolling out Google Play services 7.0 over the next few days. Expect an update to this blog post, published documentation, and the availability of the SDK once the rollout is completed.

实施后,将更新的纲领性禄

will update the programmatic l-o-c after implementation

这篇关于启用与模式高精度或电池保存位置,而无需用户需要访问设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆