Check if disambiguation is showing

73 Views Asked by At

In my app, am trying to share which shows disambiguation dialog when the share button is clicked. However spam clicking this button shows multiple instances of the disambiguation dialog. Question is how do I check that the disambiguation is already showing. I know its easier to check with DialogFragment or alertDialog but can't find anything for the disambiguation dialog showing through launching intent.

Edit: Adding code as requested

val shareIntent =  Intent(Intent.ACTION_SEND)
shareIntent.type = "image/*"
shareIntent.putExtra(Intent.EXTRA_TEXT, shareModel?.emailSubject)
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val shareUri = FileProvider.getUriForFile(context, "${context?.packageName}.fileprovider", file)
shareIntent.putExtra(Intent.EXTRA_STREAM, shareUri)
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val intent = Intent.createChooser(shareIntent, context.resources.getString(R.string.share))
context.startActivity(intent)

Update After a little bit of search/experiment, am launching intent with

context.startActivityForResult(intent, SHARE_HELPER_REQUEST_CODE)

and then in onActivityResult checking for the dialog dismissed. If anyone has a better way to do this, I will be happy to use that.

0

There are 0 best solutions below