Android的到GAE的Restlet例子在Android端不起作用 [英] Android to gae restlet example doesn't work on the Android side
问题描述
I'm trying to run restlet's first application example - android to gae - but the value returned is alway null, showing a warning in Android's LogCat: Unable to find a converter for this representation : [application/json,UTF-8]
具体code返回null是这一行:
The specific code that returns null is this line:
Contact contact = resource.retrieve();
我的假设,这是一个转换的问题。如果是这样,我很惊讶,这只是一个警告。
My Assumption that it's a conversion issue. If so, i'm surprised it's just a warning.
不知道如何走?
一些注意事项:
- 我用的Restlet 2.1.4
- 我用卷曲来测试服务器端和它的伟大工程。例如:
卷曲-i -X GET http://127.0.0.1:8888/contacts/123
- 要测试的Android针对本地服务器,我使用下面的IP:10.0.2.2
推荐答案
是的,找到了解决办法。
Yes, found a solution.
我只需要注册一个转换器 - 杰克逊特别变频器。发现在下述溶液中SO回答: http://stackoverflow.com/a/5205993/435605
I just needed to register a converter - Specifically Jackson converter. Found the solution in the following SO answer: http://stackoverflow.com/a/5205993/435605
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
我Android的应用程序类做了,因为它是一个全球性的注册,注册
The registration I did in Android's application class as it's a global registration.
这篇关于Android的到GAE的Restlet例子在Android端不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!