Using JAXB with Google Android(将 JAXB 与 Google Android 一起使用)
问题描述
我需要解析通过 xml 传递的 java 对象.我想将 JAXB 框架用于这些目的,因为我已经预先注释(使用 JAXB)java 类.
I need to parse the java-objects which are passed through xml. I want to use for these purposes JAXB framework, because I have pre-annotated (using JAXB) java-class.
这原则上可行吗?
InputStream input = entity.getContent();
JAXBContext jc = JAXBContext.newInstance(new Class[] {Response.LoginResponse.class});
Unmarshaller un = jc.createUnmarshaller();
LoginResponse response = (LoginResponse)un.unmarshal(input);
在第 4 行,我有一个警告:无法解析静态方法 282 JAXBContext ..."然后虚拟机崩溃
in line 4, I have a warning: "unable to resolve static method 282 JAXBContext ... " and then VM crashes
关于如何解决这个问题的任何想法?
Any ideas on how to solve this problem?
推荐答案
我并没有完全解决您的问题,但 JAXB 默认不包含在 android 中,该库将花费您 9(!) MB 的 apk.改用 SimpleXML.它具有类似的能力,而且更轻量级.
I'm not exactly resolving your problem, but JAXB isn't included in android by default and the library will cost you 9(!) MB of your apk. Try SimpleXML instead. It has similiar abilities and much more lightweight.
这篇关于将 JAXB 与 Google Android 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 JAXB 与 Google Android 一起使用


基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01