// Launch the image picker
imagePickerLauncher.launch("image/*");
为了检索结果,您复制以下代码
// Initialize the imagePickerLauncher
imagePickerLauncher = registerForActivityResult(new
ActivityResultContracts.GetContent(), uri -> {
if (uri != null) {
// Do something with the selected image URI
// For example, add it to the RecyclerView adapter
}
});
1条答案
按热度按时间rqmkfv5c1#
首先需要声明
private ActivityResultLauncher<String> imagePickerLauncher;
之后,这里是如何启动图像选择器
为了检索结果,您复制以下代码