As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
I have a bunch of data stored in Kinvey that I wish is access via a mobile app in Android. I have managed to do a Ping and implicit User login correctly but when trying to access my data it doesn't work. Below is my JobsEntity class that has objects set up for some but not all of the fields of data contained in the collection on Kinvey:
Hey, Can you post the entire stacktrace for the error? It looks like what is above is missing the first couple lines, and I am going to need all of that red text in logcat to figure out what the issue might be.
D
David Thomas
said
over 9 years ago
Hi,
That is the full stack trace from the LogCat in Android Studio, but here it is again:
12-05 17:48:32.265 17863-17863/com.osgs.app V/Kinvey - Client﹕ adding new instance of AppData, new collection name
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.java.core.KinveyClientRequestInitializer.initialize(KinveyClientRequestInitializer.java:98)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.java.core.AbstractKinveyClient.initializeRequest(AbstractKinveyClient.java:140)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.java.AbstractClient.initializeRequest(AbstractClient.java:186)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.java.User.retrieveBlocking(User.java:380)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.java.User.retrieveMetadataBlocking(User.java:234)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.android.AsyncUser$RetrieveMetaData.executeAsync(AsyncUser.java:935)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.android.AsyncUser$RetrieveMetaData.executeAsync(AsyncUser.java:927)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.android.AsyncClientRequest.doInBackground(AsyncClientRequest.java:65)
12-05 17:48:32.265 17863-17884/com.osgs.app W/System.err﹕ at com.kinvey.android.AsyncClientRequest$KinveySerialExecutor$1.run(AsyncClientRequest.java:128)
I have done further testing on this and it seems to be something to do with the delay in time it takes to pull back all of the data from Kinvey as there are over 400 objects. Again the code I am using to call the Kinvey backend for the data and store it in my class is:
Now say I run this app inside Android Studio in debug mode and add a watch to "myevents" when the app loads up this is empty so there are no results variables yet. After about 5 sec the "myevents" updates and now states "No such instance field: 'val$myevents' " however the results variable for the page is now full of the data from Kinvey.
I do not know why the GET function doesn't seem to wait for the call to be finished before moving on as this seems to be the problem. Is there a certain way I need to make the call for all objects? Do I have to do the call in a separate function as I am calling it in the onCreate atm?
Thanks
E
Edward
said
over 9 years ago
Hey, our android library provides asynchronous methods-- that means that all service requests are run in their own AsyncTask, and will take time to complete. You can use the callbacks to get notified when a request is complete, no matter how long it takes--
It looks like the problem here is that the GET request is being executed before the login request completes. Can you also double check that you are using the latest version of the library?
Basically, you will want to do this:
myClient = new Client.Builder(...).build();
myClient.user().login(new KinveyUserCallback(){
onSuccess(User u){
//Right here, `u` is the currently logged in user
myClient.appData(...).get(...);
}
note that login has to complete before any other request can be executed, so if you put the transition away from login in the `onSuccess` method of that login's KinveyUserCallback, you shouldn't have to worry about the timing.
David Thomas
I have a bunch of data stored in Kinvey that I wish is access via a mobile app in Android. I have managed to do a Ping and implicit User login correctly but when trying to access my data it doesn't work. Below is my JobsEntity class that has objects set up for some but not all of the fields of data contained in the collection on Kinvey:
import com.google.api.client.json.GenericJson;
import com.google.api.client.util.Key;
import com.kinvey.java.model.KinveyMetaData;
public class JobsEntity extends GenericJson {
@Key("id")
private String id;
@Key
private String comp_id;
@Key
private String company_name;
@Key
private String description;
@Key
private String job_name;
@Key
private String link;
@Key
private String sect_id;
@Key
private String deadline;
@Key("_kmd")
private KinveyMetaData meta; // Kinvey metadata, OPTIONAL
@Key("_acl")
private KinveyMetaData.AccessControlList acl; //Kinvey access control, OPTIONAL
public JobsEntity(){} //GenericJson classes must have a public empty constructor
}
The code below is on my Main Activity to try and access the data in my "jobs" collection on Kinvey:
AsyncAppData myevents = mKinveyClient.appData("jobs", JobsEntity.class);
myevents.get(new KinveyListCallback() {
@Override
public void onSuccess(JobsEntity[] result) {
Log.v("JOB DATA", "received "+ result.length + " jobs");
}
@Override
public void onFailure(Throwable error) {
Log.e("JOB DATA", "failed to fetch all", error);
}
});
The App loads up fine but I get the following Stack Trace of issue and I have no idea why:
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.java.core.KinveyClientRequestInitializer.initialize(KinveyClientRequestInitializer.java:98)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.java.core.AbstractKinveyClient.initializeRequest(AbstractKinveyClient.java:140)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.java.AbstractClient.initializeRequest(AbstractClient.java:186)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.java.User.retrieveBlocking(User.java:380)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.java.User.retrieveMetadataBlocking(User.java:234)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.android.AsyncUser$RetrieveMetaData.executeAsync(AsyncUser.java:935)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.android.AsyncUser$RetrieveMetaData.executeAsync(AsyncUser.java:927)
12-01 18:26:29.356 15489-15509/? W/System.err﹕ at com.kinvey.android.AsyncClientRequest.doInBackground(AsyncClientRequest.java:65)
12-01 18:26:29.366 15489-15509/? W/System.err﹕ at com.kinvey.android.AsyncClientRequest$KinveySerialExecutor$1.run(AsyncClientRequest.java:128)
12-01 18:26:29.376 15489-15511/? V/Kinvey - Client﹕ Serialization success
12-01 18:26:30.366 15489-15489/com.osgs.app D/KINVEY PING﹕ Kinvey Ping Success
12-01 18:26:35.056 15489-15489/com.osgs.app I/KINVEY USER LOGIN﹕ Logged in a new implicit user with id: 529b7f60798648082600f6b1
12-01 18:26:35.056 15489-15489/com.osgs.app V/Kinvey - Client﹕ adding new instance of AppData, new collection name
12-01 18:26:35.066 15489-15509/com.osgs.app I/Kinvey - Client﹕ Serialization success
12-01 18:26:35.086 15489-15538/com.osgs.app V/Kinvey - Client﹕ Serialization success
Can someone please tell me what i am doing wrong as I cant seem to figure this out.
Thanks in advance