[英]Consuming OData with Google Glass
I'm trying to consume OData within a Google Glass application. 我正在尝试在Google Glass应用程序中使用OData。 What I was doing so far is to import the required odata4j.JARs and implement a class called "PersonRequest" which extends the "AsyncTask" class.
到目前为止,我所做的是导入所需的odata4j.JARs并实现一个名为“ PersonRequest”的类,该类扩展了“ AsyncTask”类。 The class only does the following:
该类仅执行以下操作:
public class PersonRequest extends AsyncTask<Void, Void, ArrayList<Person>>{
private ArrayList<Person> persons;
@Override
protected ArrayList<Person> doInBackground(Void... params){
int i = 0;
String serviceURL = "http://services.odata.org/OData/OData.svc/";
ODataConsumer myConsumer = ODataConsumers.create(serviceURL);
for(OEntity category : myConsumer.getEntities("Categories").execute()){
String categoryName = category.getProperty("Name", String.class).getValue();
System.out.println("Category: " + categoryName);
}
return(this.persons);
}
I call this class when I switch from one view to another by the following code: 当我通过以下代码从一个视图切换到另一个视图时,我称为此类:
new PersonRequest().execute()
The problem that I have right now is that I always get an error which says the following: 我现在遇到的问题是,我总是收到一条错误消息,内容如下:
FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground() ...
Caused by: java.lang.IllegalArgumentException: Unknown ODataVersion 3.0
I've actually downloaded the latest OData-Package-Version 0.7 from the official odata4j website and added "odata4j-0.7.0-clientbundle.jar" to it but this seems not to work... Does anybody known how I can solve my problem??? 我实际上已经从odata4j官方网站上下载了最新的OData-Package-Version 0.7,并在其中添加了“ odata4j-0.7.0-clientbundle.jar”,但这似乎无法正常工作。有人知道我能解决我的问题吗?问题??? Looking forward to your answers!
期待您的回答!
Greetings Stef 问候Stef
found finally the solution ;) The problem is really caused by the ODataVersion... somehow it is not possible to consume data which comes from versions higher than 2.0! 终于找到了解决方案;)问题确实是由ODataVersion引起的...以某种方式无法使用高于2.0版本的数据!
Greetings 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.