Native Android screenshot/image sharing in Unity

This post was originally posted at https://agrawalsuneet.github.io/blogs/native-android-image-sharing-in-unity/ and reposted on Medium on 10th Aug 2018.
//Java
String screenShotPath = "fireblock_highscore.png";
Uri uriToImage = Uri.fromFile(new File("file://" + screenShotPath));
String shareSubject = "I challenge you to beat my high score in Fire Block";
String shareMessage = "I challenge you to beat my high score in Fire Block. " +
"Get the Fire Block app from the link below. \nCheers\n\n" +
"http://onelink.to/fireblock";


Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);


shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSubject);
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);

shareIntent.setType("image/png");
startActivity(Intent.createChooser(shareIntent, "Share your high score"));
//Kotlin
val screenShotPath = "fireblock_highscore.png"
val
uriToImage = Uri.fromFile(File("file://" + screenShotPath))

val shareSubject = "I challenge you to beat my high score in Fire Block"
val
shareMessage = "I challenge you to beat my high score in Fire Block. " +
"Get the Fire Block app from the link below. \nCheers\n\n" +
"http://onelink.to/fireblock"

val
shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND

shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage)
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSubject)
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage)

shareIntent.type = "image/png"
startActivity(Intent.createChooser(shareIntent, "Share your high score"))

Please continue reading at https://agrawalsuneet.github.io/blogs/native-android-image-sharing-in-unity/

--

--

--

https://agrawalsuneet.github.io/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

10 Tips To Transform From A Beginner To An Intermediate Developer.

An Introduction To Kafka

My Developer journey so far.

More Dynamic Way to Schedule a Salesforce Flow with Invocable Schedule Flow

What is 5G Core and why is it so important?

How to Add googling skills in your AI/chatbot

BEST PROGRAMMING LANGUAGES FOR BEGINNERS

The best git strategy in 2022

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Suneet Agrawal

Suneet Agrawal

https://agrawalsuneet.github.io/

More from Medium

Implementing Android 6.0 permissions in Unity3D

Unity native GPS plugin (iOS and Android)

How To Inspect Elements On Android Devices?

Custom Android Studio Plugin with IntelliJ-platform-plugin-template