I am developing an app using Kinvey as backend. The problem i am getting is that when i call a kinvey appData request then the control don't go into onsuccess method of kinvey call and return back to the calling method place. Here is my main class where i am calling a function which has kinvey client call to fetch data.
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
}
now here is my GetAllCategories function
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");
}
}
});
}
but control goes back to oncreate method just after executing kinvey call and don't go to the onSuccess method. After executing whole oncreate method it come back to onSuccess. but till then app got crash due to NUll pointer exception.
pardon my bad formating, ask me if anything you want me to explain more. Anticipatory thanks