private String clockInId;
public void clockIn(View v) {
SimpleDateFormat sdfTime = new SimpleDateFormat("hh:mm:ss a", Locale.US);
final String clockInTime = sdfTime.format(new Date(System.currentTimeMillis()));
final ParseObject clockIn = new ParseObject("clockIn");
clockIn.put("Time", clockInTime);
clockIn.saveEventually(new SaveCallback() {
@Override
public void done(ParseException e) {
clockInId = clockIn.getObjectId(); //Save objectID that was just created
}
});
Toast toast = Toast.makeText(MainActivity.this, "Clocked In!",Toast.LENGTH_LONG);
toast.show();
Log.d(TAG, "objId:" + clockInId);
}
getObjectId()
一直返回null,我错过了什么?解析对象保存得很好。
答案 0 :(得分:0)
我将saveEventually
更改为saveInBackground
:
clockIn.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
clockInId = clockIn.getObjectId(); //Save objectID that was just created
Log.d(TAG, "objId:" + clockInId);
}