This particular script will help you to implement native Android image sharing using Android’s FileProvider
in Unity. This is a fix for “android.os.FileUriExposedException” in Android 8 (Oreo) and above.
We use all the native classes of Android in Unity using AndroidJavaClass
and AndroidJavaObject
and perform the Android’s ACTION_SEND
with EXTRA_SUBJECT
, EXTRA_TEXT
and EXTRA_STREAM
.
The content type is set to image/png
in the below example but you can change it to any type and share other formats also.
For further explaination on how this works, please read the article Native Android image sharing in Unity using FileProvider.