1

App Huawei Email cut link after comma that I pass through Intent.

val intent = Intent().apply {
                action = Intent.ACTION_SEND
                type = "text/plain"
                putExtra(Intent.EXTRA_TEXT, "https://vk.com/lists?items=521168,658994,647670,662246,611036,658363")

Someone can tell why this is happening and how to fix it?

enter image description here

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
Денис
  • 75
  • 5

1 Answers1

1

this happens because links can't contain this character as plain in fact, properly formatted link should be HTML encoded with ASCII

val encodedLink = URLEncoder.encode(
    "https://yourlinkwithcommas",
    java.nio.charset.StandardCharsets.UTF_8.toString()
)

in your case it will exchange every coma char , with %2C - html encoded value. now just put encodedLink as Intent.EXTRA_TEXT. more info in HERE

snachmsm
  • 17,866
  • 3
  • 32
  • 74