在处理J2ME可选API [英] Handling Optional APIs in J2ME

查看:128
本文介绍了在处理J2ME可选API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是Java中移动?

What is the right way of working with optional APIs in Java Mobile?


  • 做一件需要做出不同的版本他们的应用程序吗?

  • 或者是足够使用检查在运行时API可用性 System.getProperty()

  • Does one need to make different versions of their app?
  • Or is it enough to check APIs availability at runtime using System.getProperty()?

比方说,我想我的应用程序,支持JSR-256(传感器API)。将从 javax.microedition.sensor 导入类和注册这些类型的变量打破我的应用程序,如果设备不支持呢?

Let's say I'd like my app to support JSR-256 (the Sensor API). Would importing classes from javax.microedition.sensor and registering variables of these types break my app if the device doesn't support it?

我相信一定有处理这种情况一个pretty标准方式。

I am sure there must be a pretty standard way of handling that situation.

谢谢!

推荐答案

您可以使用系统属性,或调用Class.forName()来查看是否API可用。只要使用这些API确保类不被装载在不支持他们的手机。你可以让你的MIDlet的一个版本,它支持许多不同的手机。

You can use system properties, or Class.forName() to see if the API is available. Just make sure classes using those APIs don't get loaded on handsets that don't support them. You can make one version of your midlet that supports many different handsets.

这篇关于在处理J2ME可选API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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