简体   繁体   中英

Consuming OData with Google Glass

I'm trying to consume OData within a Google Glass application. What I was doing so far is to import the required odata4j.JARs and implement a class called "PersonRequest" which extends the "AsyncTask" class. 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??? Looking forward to your answers!

Greetings 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!

Greetings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM