admin管理员组文章数量:1301502
On some android devices after selecting contact I am getting RESULT_CANCELED and intent == null. Here is my code:
val contactLauncher = rememberLauncherForActivityResult(object : ActivityResultContract<Int?, Uri?>() {
override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
return if (resultCode == Activity.RESULT_OK) intent?.data else null
}
override fun createIntent(context: Context, input: Int?): Intent =
Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI).also {
it.type = ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE
}
}) { uri ->
...
}
...
contactLauncher.launch(null)
I have also manually asked for contact read permission.
> Doesn`t work on Pixel 8a(Android 15), Pixel 5a(Android 14), Xiaomi Poco C40(Android 14)
> Works on Pixel 8a(Android 15-virtual device), Honor x8a(Android 14), Samsung Galaxy A55(Android 14)
On some android devices after selecting contact I am getting RESULT_CANCELED and intent == null. Here is my code:
val contactLauncher = rememberLauncherForActivityResult(object : ActivityResultContract<Int?, Uri?>() {
override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
return if (resultCode == Activity.RESULT_OK) intent?.data else null
}
override fun createIntent(context: Context, input: Int?): Intent =
Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI).also {
it.type = ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE
}
}) { uri ->
...
}
...
contactLauncher.launch(null)
I have also manually asked for contact read permission.
> Doesn`t work on Pixel 8a(Android 15), Pixel 5a(Android 14), Xiaomi Poco C40(Android 14)
> Works on Pixel 8a(Android 15-virtual device), Honor x8a(Android 14), Samsung Galaxy A55(Android 14)
Share
Improve this question
edited Feb 11 at 11:09
Mery Karapetyan
asked Feb 11 at 8:41
Mery KarapetyanMery Karapetyan
2012 silver badges8 bronze badges
1
- Please edit the question to add what kind of devices this doesn't work for. Is it a specific API level, is it a specific manufacturer or something else? How can the issue be reproduced? – tyg Commented Feb 11 at 9:01
1 Answer
Reset to default 0The reason was that launchMode was set to singleInstance, after changing to singleTask everything worked.
版权声明:本文标题:android - Picking contact from contacts list not working on some devices (Jetpack compose) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741669892a2391538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论