Java 在firebase Android studio中更新用户档案图像
我有一个用户注册的应用程序,可以有一个个人资料图像。在实时数据库中,我保存了这些信息。现在我希望能够更改信息,特别是个人资料图像。这是我的实时数据库: 当用户点击他/她的图像时,相机意图开始:Java 在firebase Android studio中更新用户档案图像,java,android,firebase,firebase-realtime-database,Java,Android,Firebase,Firebase Realtime Database,我有一个用户注册的应用程序,可以有一个个人资料图像。在实时数据库中,我保存了这些信息。现在我希望能够更改信息,特别是个人资料图像。这是我的实时数据库: 当用户点击他/她的图像时,相机意图开始: private void startCamera() { //start the camera Intent cInt = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResu
private void startCamera() {
//start the camera
Intent cInt = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cInt,REQUEST_IMAGE_CAPTURE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE) {
if (resultCode == RESULT_OK) {
//picture as image
Bitmap bp = (Bitmap) data.getExtras().get("data");
mProfileRoundedImageView.setImageBitmap(bp);
//here I want to save Image uri and update my firebase with the new uri...
}
}
}
我该怎么做??我已经搜索了很多如何将捕获的图像转换为uri,然后更新imageurl,但没有运气。请帮忙
顺便说一句,我不想将图像保存到sd,只需转换为uri并更新firebase…您可以使用以下功能
public Uri getImageUri(Context inContext, Bitmap inImage) {
Bitmap OutImage = Bitmap.createScaledBitmap(inImage, 1000, 1000,true);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), OutImage, "Title", null);
return Uri.parse(path);
}
提取位图后,只需在onActivityResult()中调用它
请随时询问是否有不清楚的地方当我试图理解我的代码时,您能否解释代码:)首先检查它是否对您有效。它看起来对我无效:/错误是什么?当我尝试更新我的配置文件时,它看起来没有更新。我得到的uri是:
content://media/external/images/media/24
我不确定它应该是这样的。它不应该看起来像一个url吗?