【发布时间】:2021-07-31 22:44:30
【问题描述】:
用户可以在更新个人资料照片时从其设备的图库中选择一张照片。应用在用户选择照片之前请求权限。但问题是,当用户卸载该应用程序并再次安装时,他们将不再看到他们的个人资料照片,因为他们需要再次允许该权限。我使用此代码更新用户个人资料照片:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val userPhoto: CircleImageView = findViewById(R.id.userImage)
if (requestCode == OPEN_GALLERY_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
val imageUri = data?.data
userPhoto.setImageURI(imageUri)
var user = Utils().getCurrentUser()
val profileUpdates: UserProfileChangeRequest =
UserProfileChangeRequest.Builder()
.setPhotoUri(imageUri)
.build()
user?.updateProfile(profileUpdates)?.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d("ProfileChange", "User profile updated.")
Log.d("ProfileChange","${imageUri}")
}
}
}
}
Logcat 输出为:D/ProfileChange: content://media/external/images/media/19344
是否有任何解决方案让用户在卸载并重新安装应用后无需接受任何权限即可查看其个人资料照片?
【问题讨论】:
-
READ_EXTERNAL_STORAGE 权限。
-
所以你想接受一次,并在以后的应用安装中使用它,对吧?
标签: android firebase firebase-authentication firebase-storage android-permissions