English 中文(简体)
安德森图书馆目标汇编和文稿
原标题:Android Library target compilation and objects in later Android versions

我正在建造一座安乐器图书馆,并有一个办法,获取有关该装置的一些信息。 我们的目标是支持2.2和补充,但想知道,有办法收集后来版本(第2.3号装置序列)中介绍的信息,并用第2.2版汇编申请。

在对我进行搜捕之后,发现有人使用诸如:

private static String getHardwareSerial() {
    try {  
        return Build.SERIAL;
    } catch (VerifyError e) {
        //Android 8 and previous did not have this information
        return Build.UNKNOWN;  
    }
}

然而,由于该守则的存在,我利用我们的图书馆进行的抽样应用在设定建筑目标到8时时未能建立。 任何建议,或者我们是否必须同我们的客户一起,确定他们的目标,达到9岁,以获得这一信息?

问题回答

你可以通过思考来做到这一点:

public static String getHardwareSerial() {
    try {
        Field serialField = Build.class.getDeclaredField("SERIAL");
        return (String)serialField.get(null);
    }
    catch (NoSuchFieldException nsf) {
    } 
    catch (IllegalAccessException ia) {
    }
    return Build.UNKNOWN;
}

如果实地发现(在较早版本的非洲顾问办上)的话,就会放弃一个例外,而这种例外将被忽视,随后又会落到返回建筑。 UNKNOWN。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签