LocationProvider.getInstance() 始终返回 null
在我的 Java ME 应用程序中,LocationProvider.getInstance(null) 始终在模拟器中返回 null。
应用程序处于早期状态,所以我没有在真机上尝试。
我相信,我阅读了所有关于 Location API 的文章,但我仍然不明白为什么它会发生在我身上。
它在不同的项目中运行良好,在同一模拟器上具有相同的设置。
代码如下:
if(currentLp == null)
{
try
{
System.err.println("nope");
currentLp = LocationProvider.getInstance(null);
} catch (LocationException ex)
{
System.err.println("Ooops!");
}
}
来自 SDK3.0
的 DefaultCLDCPhone01 上的 CLDC-1.1、MIDP-2.1、Location API 1.0
In my Java ME app, LocationProvider.getInstance(null) always returns me null in emulator.
App in early state, so I didn't tried on real phone.
I believe, I read every article about Location API, but I still don't get, why it's happening to me.
It works fine in different projects, with same settings on same emulator.
Here's the code:
if(currentLp == null)
{
try
{
System.err.println("nope");
currentLp = LocationProvider.getInstance(null);
} catch (LocationException ex)
{
System.err.println("Ooops!");
}
}
CLDC-1.1, MIDP-2.1, Location API 1.0
on DefaultCLDCPhone01 from SDK3.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LAPI 1.0 - JSR 179。在此版本规范中,如果无法返回满足定义条件的 LocationProvider,但有其他受支持的可用或暂时不可用的提供程序不满足条件,则
LocationProvider.getInstance
返回 null。oops JSR293< /a>?这是 LAPI
2.0
而不是1.0
。无论它指定什么,它与您的情况无关,因为正如您所写,它支持早期版本规范。对于您的情况,请使用 JSR 179。或者配置 DefaultCLDCPhone 以支持 JSR 293(如果可能)(应该在模拟器用户指南中)LAPI 1.0 - JSR 179. In this version specification,
LocationProvider.getInstance
returns null "if a LocationProvider that meets the defined criteria can't be returned but there are other supported available or temporarily unavailable providers that do not meet the criteria."oops JSR293? That's LAPI
2.0
not1.0
. Whatever it specifies, it has nothing to do with your case since as you wrote, it supports earlier version specification. For what to expect in your case, use JSR 179. Or configure DefaultCLDCPhone to support JSR 293 if that's possible (that should be in emulator User Guide)