I want my app to be able to share a link, and I'm using the Intent chooser to do it. The first option is always "Nearby Share". So if the user picks Nearby Share, the receiver gets the link and has the option to open it. I would like to have the same behaevior with Huawei Share. But the receives gets a text file. Is it possible to just share the link? So the user that received it could just open it in their phone? Instead of getting a text file with the link in it?
This is what I tried, and it works for any regular phone but not Huawei phones. For Huawei Share it is a text file.
val urlIntent = Intent(ACTION_SEND)
urlIntent.type = "text/plain"
urlIntent.putExtra(EXTRA_TEXT, "some text ${urlToShare}")
Intent.createChooser(urlIntent, "").apply {
putExtra(
Intent.EXTRA_REPLACEMENT_EXTRAS,
bundleOf(
"com.google.android.gms" to bundleOf( // Nearby share specific text
EXTRA_TEXT to urlToShare
),
"com.huawei.hms.nearby" to bundleOf( // Nearby share for Huawei
EXTRA_TEXT to urlToShare
)
)
)
}