I want to share an image using it’s URI to Twitter. When I click a button I want a Chooser to pop up with only twitter functions. I did it like this before Android 11
val shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND
shareIntent.setPackage("com.twitter.android")
shareIntent.putExtra(Intent.EXTRA_STREAM, imgUriForShare)
shareIntent.type = "image/*"
Intent.createChooser(shareIntent, "Share Image")
deleteTempImageLauncher.launch(shareIntent)
Facebook solved this problem by telling us to add this to the manifest:
<queries>
<provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
</queries>
Is there a similar way to solve it for Twitter?
There are extra things you need to do to upload media to twitter - you will need to implement or use a library that implements chunked media upload Chunked media upload | Docs | Twitter Developer Platform you will also need to retrieve the image and upload bytes - not a URI