- Home /
Android Share text and image?
Hi,
I have the following code that allows me to share some text on an android device and it is working fine:
public void DoShare(string text)
{
AndroidJavaClass intentClass = new AndroidJavaClass ("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject ("android.content.Intent");
intentObject.Call<AndroidJavaObject> ("setAction", intentClass.GetStatic<string> ("ACTION_SEND"));
intentObject.Call<AndroidJavaObject> ("setType", "text/plain");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "SUBJECT");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), text);
AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity");
currentActivity.Call ("startActivity", intentObject);
}
but how can I make it so I can share an image as well as the text? Can anyone help me?
Any help is greatly appreciated, Thanks.
Hello, @12boulla. I hope this article answers your question: http://www.daniel4d.com/blog/sharing-image-unity-android/comment-page-1/
Answer by Voxel-Busters · Feb 16, 2016 at 04:49 AM
@12boulla You should be easily able to convert below to JNI calls.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
String mimeType = "image/*"
// Set MIME type based on the available content
shareIntent.setType(mimeType);
// Set text here
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, message );
// Set image path here
if (!StringUtility.isNullOrEmpty(imagePath))
{
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imagePath));
}
The above code is from Cross Platform Native Plugins and you can grab a free copy of Lite version which includes Sharing feature along with many others.
Answer by Guhanesh · Feb 16, 2016 at 05:40 AM
refer this page http://www.thegamecontriver.com/2015/09/unity-share-post-image-to-facebook.html?showComment=1455523299779#c1485580557316768963
Answer by Roixo · May 28, 2018 at 02:51 PM
Hi,
I made this tutorial where you can share screenshoots of the game in all Social Media (Facebook, Twitter, Whatsapp, Instagram, Gmail and so on) in less than 20 lines of code just with one single button:
Answer by mansion77official · Dec 10, 2021 at 11:43 AM
Agen Slot Online Terpercaya 2021 - 2022 | Situs Judi Slot Online Terbesar dan Terbaik | Daftar Situs Slot Online Terbaik dan Terlengkap Mansion77
VERY GOOD CONTENT, THANKYOU FOR SHARING!!
https://188.166.207.181/ https://heylink.me/mansion77 https://www.flowcode.com/page/mansion77 https://joy.link/mansion77 https://linktr.ee/mansion77 https://beacons.ai/mansion77 https://www.purocasting.com/community/profile/agen-slot-online-terlengkap https://www.zoimas.com/profile/mansion77 https://isovle.net/blog/index.php?entryid=19758 https://mansion77slot.blogspot.com/