@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SELECT_PICTURE) {
if (resultCode == RESULT_OK) {
Bitmap bitmap = null;
if (data != null) {
try {
bitmap = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
} catch (IOException e) {
e.printStackTrace();
}
userPicImageView.setImageBitmap(bitmap);
dialog = new ProgressDialog(this);
dialog.setTitle("Updating profile picture");
dialog.setMessage("Please, wait");
dialog.show();
final BackendlessUser user = Backendless.UserService.CurrentUser();
Backendless.Files.Android.upload(bitmap, Bitmap.CompressFormat.JPEG, 100, "profile_pic_" + user.getObjectId() + System.currentTimeMillis(), "images", new AsyncCallback<BackendlessFile>() {
@Override
public void handleResponse(final BackendlessFile response) {
Log.d(TAG, "updated profile pic");
Log.d(TAG,"FILE URL IS "+response.getFileURL().toString());
backendlessFile = response;
if (dialog.isShowing()) {
dialog.dismiss();
}
String currentUserID = Backendless.UserService.loggedInUser();
Backendless.UserService.findById(currentUserID, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser usr) {
Log.d(TAG,"CURRENT USER is "+usr.getProperty("name").toString());
usr.setProperty("image", response.getFileURL().toString());
Backendless.UserService.update(usr);
}
@Override
public void handleFault(BackendlessFault fault) {
[**problem here**-->] Log.e(TAG,"COULD NOT LOAD user");
}
});
}
@Override
public void handleFault(BackendlessFault fault) {
Log.e(TAG, "error " + fault.getMessage());
}
});
}
}
}
}
以上代码处理用户使用图库中的图片更新其个人资料时的情况。她将文件上传到Backendless文件存储。 Users表格中有一列&#34;图像&#34;存储配置文件图片的链接。我尝试通过将图像字段设置为包含上传文件的链接来检索当前用户并更新她的行,但是日志说他们无法访问用户(错误位置标记为问题 in上面的代码)。这都与Async请求有关吗?如何解决这个问题?
[编辑]我发现这一切都与Async调用确实有关。问题是,Backenledss AsyncCallback似乎没有onPostExecute()方法。