Search code examples
androidhuawei-mobile-serviceshuawei-developers

Huawei email cut link after comma


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


Solution

  • 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