我正在使用parse.com android应用程序,我想在其中获取自定义表“UserInfo”的ObjectId。我使用了以下代码行,但是它为ObjectId提供了Null值,并且无法从服务器获取ObjectId。请告诉我如何获得ObjectId。
public static ParseObject userINfo = new ParseObject("UserInfo");
String info_ = userINfo.getObjectId();// Null Value
String infow = userINfo.getString("objectId");// Null Value
答案 0 :(得分:1)
我刚刚解决了我的问题。它的工作原理是使用CallBackMethod。代码如下:
public static ParseObject user= new ParseObject("UserInfo");
user.getParseObject("info").fetchIfNeededInBackground(new GetCallback<ParseObject>() {
@Override
public void done(ParseObject object, ParseException e) {
// TODO Auto-generated method stub
ParseObject userinfo = object;
String doctor = userinfo.getString("door");
String allergies = userinfo.getString("algies");
String medicalNote = userinfo.getString("mediote");
String medications = userinfo.getString("medic");
String medicalCondition = userinfo.getString("medicalCondition");
docInfo.setText(doctor);
medication.setText(medications);
medNotes.setText(medicalNote);
medCond.setText(medicalCondition);
alergiesReact.setText(allergies);
Log.i("userinfo", "" + userinfo);
}
});