冰淇淋三明治的位置管理器问题 [英] location manager issue for ice cream sandwhich

查看:37
本文介绍了冰淇淋三明治的位置管理器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下这个错误是什么?我只为 android 4 + 而不是以下:

can anybody explain me what is this error ? I am getting only for android 4 + and not for below:

E/AndroidRuntime(891): java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.example.getaddress/com.example.getaddress.MainActivity}: java.lang.IllegalArgumentException: 请求的提供者网络没有'不存在

推荐答案

在 Android 4+ 模拟器中似乎无法访问 NETWORK_PROVIDER 位置提供程序没有 Google API(其实我有未对所有这些进行测试,请参见下文).我测试过的真实设备都可以使用它(但它们都有 Google 服务,用自定义、干净的 Android 版本进行测试会很有趣,也许用 Kindles?).

It appears that the NETWORK_PROVIDER location provider is not accessible in Android 4+ emulators without Google APIs (well actually I have not tested on all of them ,see below). The real devices I have tested on are OK with it (but they all have Google services on them, it would be interesting to test with custom, clean Android versions, maybe with Kindles?).

这不是在设备设置中启用/禁用提供程序的问题,它根本不存在于模拟器中.

It is not a question on enabling/disabling the provider in the device settings, it is simply not there in the emulator.

基本上这段代码:

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,0,mLocListener);

会导致以下异常:

java.lang.IllegalArgumentException: provider doesn't exisit: null

在所有 Android 4+ 裸机模拟器上(与谷歌绑定的模拟器相反)

on all Android 4+ naked emulators (as opposed to Google-bound emulators)

注意:exisit"中的错字在实际日志行中.

使用以下内容获取目标设备上所有位置提供程序的列表:

Getting a list of all location providers on the target device with the following:

List<String> providers = locationManager.getAllProviders();

我可以看到网络提供商存在于

I can see that the network provider is present on

  • 物理设备
  • android 2.3.3 模拟器(无 Google API)
  • android 17 级 (4.2) 模拟器(使用 Google API)

但不在

  • 带有 Google API 的 android 级别 15 (4.0.3) 模拟器
  • android 4.2 模拟器(无 Google API)

我的猜测是,出于非技术原因,Google 不允许在 AOSP 中使用 network 定位服务,并将其使用限制为从 4.2 (?) 起与 Google 绑定的操作系统版本.

My guess is that for non-technical reasons, Google has not allowed the network location service in AOSP and limited its usage to the Google-bound versions of the OS from 4.2 (?).

我不知道在非 Google 设备(例如 Kindle)上是否有替代网络位置服务.

What I don't know if whether or not there is a replacement network location service on non-Google devices (such as Kindle).

我认为这不会对大多数智能手机和平板电脑产生任何影响.不过可以

I would not expect this to have any impact on most smartphones and tablets. However it can

  • 在某种程度上影响您的测试能力
  • 对于使用自定义/非 Google 版本的 Android(又是 Kindle?)的用户来说是一个兼容性问题

一个简单的测试,例如:

A simple test such as:

locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)

可以轻松地告诉您设备上是否存在网络提供商.请注意,如果它存在,但用户尚未激活它,您的 LocationListener 将在位置请求之后收到 onProviderDisabled 回调.

can tell you painlessly if the network provider is present on the device. Note that if it is present, but the user has not activated it, your LocationListener will receive an onProviderDisabled callback following the location request.

这篇关于冰淇淋三明治的位置管理器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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