为什么java.text.Normalizer可以在我的Andr​​oid 2.2手机? [英] Why is java.text.Normalizer available on my Android 2.2 phone?

查看:182
本文介绍了为什么java.text.Normalizer可以在我的Andr​​oid 2.2手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这事难不倒我...

我检查我的code,并决定构建目标改变,从2.3到2.2,以确保每2.3 API,我使用的是包裹在一个不错的android.os.Build.VERSION.SDK_INT检查。

I was checking my code, and decided to change the build target from 2.3 to 2.2 to make sure every 2.3 API that I use is wrapped in a nice android.os.Build.VERSION.SDK_INT check.

但地方我做出java.text.Normalizer.normalize(呼叫)不检查SDK版本。好奇,为什么这不是由QA发现,我开始应用2.2手机在调试模式上的正常工作的!

But somewhere I make a call to java.text.Normalizer.normalize() that does not check for the SDK version. Curious as why this wasn't found by QA, I started the app on a 2.2 phone in debug mode and it works fine!

该手机是LG-P505R版本2.2.2。

The phone is a LG-P505R version 2.2.2.

那么,为什么这2.2手机能拨打在2.3中添加的某些API?

So, why does this 2.2 phone can call some API that were added in 2.3?

这是我能想到的唯一合乎逻辑的解释是,制造商已经加入该API到Android栈。

The only logical explanation that I could think of is that the manufacturer has added this API to the Android stack.

[更新]更多...疯狂

[Update] More madness...

我测试在2.2这个code。模拟器并能正常工作:

I tested this code on a 2.2. emulator and it works fine:

public class NormalizerTestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final String s = "This \"é\" will become an \"e\"";

        final TextView tv = (TextView) findViewById(R.id.tv);

        final String temp = Normalizer.normalize(s, Normalizer.Form.NFD);
        final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
        final String strNormalized = pattern.matcher(temp).replaceAll("");

        tv.setText(strNormalized);
    }
}

推荐答案

所以现在我唯一的猜测是,它是在2.3公之于众,但它在那里一直...

So for now my only guess is that it was made public in 2.3, but it was there all along...

这篇关于为什么java.text.Normalizer可以在我的Andr​​oid 2.2手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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