1
我正在開發一個應用程序,使用Kinvey作爲後端。我遇到的問題是,當我調用kinvey appData請求時,控件不會進入kinvey調用的onsuccess方法並返回到調用方法位置。 這裏是我的主要類,我正在調用一個函數,它具有kinvey客戶端調用來獲取數據。kenvey客戶端調用的onsuccess方法如何同步
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_image_list);
// kinvey login here//
// here is the function that fetch my data from kinvey
GetAllCategory();
imageUrls=urls // this is the assignment that cause Null pointer Exception
}
現在這裏是我的GetAllCategories功能
public void GetAllCategory(){
AsyncAppData<EntityCategories> myEvents=mKinveyClient.appData("categories", EntityCategories.class);
myEvents.get(new Query(), new KinveyListCallback<EntityCategories>(){
@Override
public void onFailure(Throwable error) {
// TODO Auto-generated method stub
Log.e(TAG, "failed to save event data", error);
}
@Override
public void onSuccess(EntityCategories[] result1) {
// TODO Auto-generated method stub
// Log.e(TAG,"Name is "+result1[0].get("name"));
// Log.e(TAG,"type is"+result1[0].get("type"));
categories=result1;
//onPrintCategoryClick();
for(int i=0;i<categories.length;i++){
imageUrls[i]=(String) categories[i].get("icon");
}
}
});
}
,但只是執行kinvey調用之後控制回到onCreate方法,不要去到的onSuccess方法。執行完整的oncreate方法後,它返回到onSuccess。但直到那時,由於NUll指針異常,應用程序崩潰。
請原諒我的錯誤格式化問題,請問我是否希望我解釋更多。預期感謝