从Kinvey后端获取数据

时间:2013-08-09 12:07:20

标签: android loaddata kinvey

我使用kinvey作为我的后端,我有一个集合,并希望使用appData.get获取数据。我尝试使用下面的代码,但它不起作用。有人可以告诉我它有什么问题。

package com.example.kinvey;

import com.kinvey.android.AsyncAppData;
import com.kinvey.android.callback.KinveyListCallback;
import com.kinvey.java.core.KinveyClientCallback;

import android.app.Activity;
import android.content.Entity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;

public class ActionData extends Activity{

//protected static final String TAG = "LOG:";
public static final String TAG = "ActionData";

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.display);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // TODO Auto-generated method stub
    return super.onCreateOptionsMenu(menu);
}

public void onLoadClick(View view) {

    AsyncAppData<Entity> myevents = MainActivity.mKinveyClient.appData("events",Entity.class);
    myevents.get(new KinveyListCallback<Entity>()     {
      @Override
      public void onSuccess(Entity[] result) { 
        Log.v(TAG, "received "+ result.length + " events");
      }
      @Override
      public void onFailure(Throwable error)  { 
        Log.e(TAG, "failed to fetch all", error);
      }
    });     
}

这是我的实体课程。

package com.example.kinvey;

import com.google.api.client.json.GenericJson;
import com.google.api.client.util.Key;
import com.kinvey.java.model.KinveyMetaData;

public class Entity extends GenericJson{

@Key("_id")
private String id; 

@Key("_class")
private String _class;

@Key("author")
private String author;

@Key("relatedObj")
private String relatedObj;

@Key("relatedObjName")
private String relatedObjName;

@Key("type")
private String type;

@Key("_kmd")
private KinveyMetaData meta; 

@Key("_acl")
private KinveyMetaData.AccessControlList acl; 

public Entity(){}  

public String getActionId() {
    return id;
}

public void setActionId(String id) {
    this.id = id;
}

public String getclass() {
    return _class;
}

public void setclass(String _class) {
    this._class = _class;
}

public String getAuthor() {
    return author;
}

public void setAuthor(String author) {
    this.author = author;
}

public String getRelatedObj() {
    return relatedObj;
}

public void setRelatedObj(String relatedObj) {
    this.relatedObj = relatedObj;
}

public String getRelatedObjName() {
    return relatedObjName;
}

public void setRelatedObjName(String relatedObjName) {
    this.relatedObjName = relatedObjName;
}

public String getType() {
    return type;
}

public void setType(String type) {
    this.type = type;
}

}

0 个答案:

没有答案