不能在Android的调用String.isEmpty() [英] can't call String.isEmpty() in android

查看:216
本文介绍了不能在Android的调用String.isEmpty()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我不能使用 String.isEmpty()功能,这是坐落在JDK 1.6。 Android 2.1的lib中没有此功能java.lang.String中类

我试着输入JRE系统库到我的项目,因为它有这个功能,但没有效果。

我该如何解决这个问题,让我的应用程序使用此功能?

解决方案
  

我该如何解决这个问题,让我的应用程序使用此功能?

您不能。

使用 string.length减()== 0 代替。它是向后兼容所有的方式回到JDK 1.0 ... ...和J2ME为好。

String.equals()是另一种选择。


  

您肯定是没有办法来配置Eclipse来投入code类的明确的图书馆?

如果你希望你的应用程序,以一个的真正的Andr​​oid设备上运行没有。的Java / Android的平台故意让你很难鼓捣核心类库的行为。一开始,你只能做它通过修改Davlik相当于BOOTCLASSPATH或的rt.jar 的文件,并没有这些可以运行的JVM内完成。

那种修修补补具有的危险的潜在破坏Java的其他应用程序。即使假设你不能妥协,恶意调整到(共享)的Java核心类仍然可以潜在地允许一个应用程序的干扰,或从其他应用程序窃取信息(因为下面提到的过程/ UID分离)直接Android应用程序分离

In my android application I can't use String.isEmpty() function which is situated in JDK 1.6. Android 2.1 lib doesn't have this function in java.lang.String class

I tried to input JRE System library to my project, because it has this function, but there was no effects.

How can I solve this problem and allow my application to use this function?

解决方案

How can I solve this problem and allow my application to use this function?

You can't.

Use String.length() == 0 instead. It is backwards compatible all the way back to JDK 1.0 ... and with J2ME as well.

String.equals("") is another alternative.


Are you sure that there is no way to configure Eclipse to put into a code classes from definite libraries?

Not if you want your app to run on a real Android device. Java / Android platforms intentionally make it hard for you to tinker with the behaviour of the core class libraries. For a start, you can only do it by modifying the Davlik equivalent of the bootclasspath or rt.jar file, and neither of these can be done within a running JVM.

That kind of tinkering has the risk of potentially breaking Java for other apps. Even assuming that you can't compromise Android app separation directly (because of the process/uid separation mentioned below), malicious tweaks to the (shared) Java core classes could still potentially allow one app to interfere with, or steal information from another app.

这篇关于不能在Android的调用String.isEmpty()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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