This is my code:
package com.example.toggleDemo;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import org.odata4j.consumer.ODataConsumer;
import org.odata4j.core.OEntity;
import org.odata4j.jersey.consumer.ODataJerseyConsumer;
import java.util.List;
import java.util.ArrayList;
public class MainActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, GetExpenseReports()));
getListView().setTextFilterEnabled(true);
}
ArrayList<String> GetExpenseReports()
{
ArrayList<String> listUI = new ArrayList<String>();
ODataConsumer c = ODataJerseyConsumer.create("http://services.odata.org/Northwind/Northwind.svc/");
List<OEntity> listCategories= (List<OEntity>) c.getEntities("Categories");
for(OEntity category : listCategories) {
listUI.add(String.format("%s-%s", category.getProperty("CategoryID").getValue().toString(), category.getProperty("CategoryName").getValue().toString()));
}
return listUI;
}
}
When run in the emulator,it's error : 08-28 17:30:05.793: ERROR/AndroidRuntime(781): FATAL EXCEPTION: main java.lang.NoClassDefFoundError: javax.ws.rs.ext.RuntimeDelegate at org.odata4j.jersey.consumer.ODataJerseyConsumer.(ODataJerseyConsumer.java:22) at org.odata4j.jersey.consumer.ODataJerseyConsumer.(ODataJerseyConsumer.java:14) at org.odata4j.jersey.consumer.ODataJerseyConsumer$Builder.build(ODataJerseyConsumer.java:93) at org.odata4j.jersey.consumer.ODataJerseyConsumer.create(ODataJerseyConsumer.java:115) at com.example.toggleDemo.MainActivity.GetExpenseReports(MainActivity.java:38) at com.example.toggleDemo.MainActivity.onCreate(MainActivity.java:22) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) at android.app.ActivityThread.access$2300(ActivityThread.java:125) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4627) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method)
Thanks in advance!
try this it worked for me ArrayList listUI = new ArrayList(); ODataConsumer c = ODataJerseyConsumer.create("http://services.odata.org/Northwind/Northwind.svc/"); OQueryRequest catagories = c.getEntities("Categories");