Native Android text sharing in Unity app

This post was originally posted at https://agrawalsuneet.github.io/blogs/native-android-text-sharing-in-unity/ and reposted on Medium on 29th Jun 2018.
//Java
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 sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSubject);
sendIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share Via"));
//Kotlon
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 sendIntent = Intent()
sendIntent.action = Intent.ACTION_SEND
sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSubject)
sendIntent.putExtra(Intent.EXTRA_TEXT, shareMessage)
sendIntent.type = "text/plain"
startActivity(Intent.createChooser(sendIntent, "Share Via"))

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

--

--

--

https://agrawalsuneet.github.io/

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

Recommended from Medium

Learning CSS — Part 1

I then forgot about Medical School and focused on getting through my last semester in college.

Apache Airflow: Maintenance and optimisation

“If it turns out that this is incurable, would you marry me?”

KRACK-JIIT CTF Writeup

Engaging a Unique Species of Worker, the Software Developer

Improving End-to-End Testing at Coursera using Puppeteer and Jest

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

How To Inspect Elements On Android Devices?

Unity native GPS plugin (iOS and Android)

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