Start a new topic

KinveyListCallback Error

Hey everyone, I'm having trouble passing some information. Here's the snipped of my code



public RestaurantNamesTable[] getRestaurantLists(Client kinveyClient, String UniversityName)
{



Query myQuery = kinveyClient.query();
myQuery.equals("University", UniversityName);
AsyncAppData<RestaurantNamesTable> myEvents = kinveyClient.appData("RestaurantNamesTable", RestaurantNamesTable.class);
myEvents.get(myQuery, new KinveyListCallback<RestaurantNamesTable>() {
@Override
public void onSuccess(RestaurantNamesTable[] results) {
Log.v("KinveyResult", "received " + results.length + " events");
Log.v("KinveyResult", results[0].getLocationName());
setRestaurantNames(results);
//restaurantItemList.setRestaurantItemList(results);
Log.v("KinveyNew", restaurantNames[1].toString());
targets = Arrays.asList(results);
Log.v("KinveyList",targets.get(0).toString());

}

@Override
public void onFailure(Throwable error) {
Log.e("TAG", "failed to fetchByFilterCriteria", error);

}
});
Log.v("KinveyOuter",this.targets.get(0).toString());
return getRestaurantNames();


} The problem is that when I do the Log.v in the onSucess method, it correctly outputs the datafield. However, in my main function RestaurantNamesTable[], running the Log.v gives me a null reference error. So it seems that data is not being passed from the inner class to the outer class. How can I fix this? Also note that RestaurantNamesTable[] restaurantNamesTable; and List<RestaurantNamesTable> targets; I was just trying different things. Help Please!!
Login or Signup to post a comment