TelegramStickersImport icon indicating copy to clipboard operation
TelegramStickersImport copied to clipboard

The sample not working, but I have figured out the solution

Open luongcuong244 opened this issue 2 years ago • 0 comments

This code works for me

   fun doImport(context: Context, stickerUris: ArrayList<Uri>) {
        val it = stickerUris.iterator()
        while (it.hasNext()) {
            context.grantUriPermission(
                "org.telegram.messenger",
                it.next(),
                Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
            )
        }

        val intent = Intent("org.telegram.messenger.CREATE_STICKER_PACK")
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, stickerUris)
        intent.putExtra("IMPORTER", context.packageName)
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
        intent.type = "image/*"

        try {
            context.startActivity(intent)
        } catch (e: ActivityNotFoundException) {
            Toast.makeText(context, context.getString(R.string.no_app_found_to_handle_this_action), Toast.LENGTH_SHORT).show()
        }
   }

luongcuong244 avatar Jan 08 '24 09:01 luongcuong244