2 回答

TA貢獻1871條經驗 獲得超13個贊
如果用戶未從圖庫中選擇圖像,則所選的ImgUri為空。
因此,當您調用 createUserAccount() 時,單擊注冊按鈕并且用戶尚未選擇圖像選擇ImgUri 不會根據您的代碼進行更新。因此,updateUserInfo() 調用導致崩潰的異常將失敗。
請?zhí)砑右粋€空檢查器,如
if(pickedImgUri!=null){
//then update the user account
}
如果您有興趣強迫用戶選擇個人資料照片,那么只需使用上面的檢查器并提醒用戶請先選擇一張照片,但我建議不要這樣做。不是每個人都喜歡上傳照片。當用戶不想更新/刪除頭像時,請使用任何通用頭像 png 文件。快樂編碼

TA貢獻1869條經驗 獲得超4個贊
多謝??!我添加了幾行,它起作用了!!!謝謝!!
if(email.isEmpty() || name.isEmpty() || password.isEmpty() || password2.isEmpty() || !password.equals(password2))
{
//something goes wrong... display an error message
showMessage("Please verify full fields!!");
regBtn.setVisibility(View.VISIBLE);
loadingProgress.setVisibility(View.INVISIBLE);
}
else
{
if(pickedImgUri == null)
{
showMessage("Please select an image");
regBtn.setVisibility(View.VISIBLE);
loadingProgress.setVisibility(View.INVISIBLE);
}
else {
createUserAccount(email, name, password);
//Everything is ok..
}
}
}
});
添加回答
舉報