Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by 12boulla · Feb 15, 2016 at 08:54 PM · androidtextimageshareandroidjavaobject

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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EmHuynh · Feb 15, 2016 at 09:46 PM 0
Share

Hello, @12boulla. I hope this article answers your question: http://www.daniel4d.com/blog/sharing-image-unity-android/comment-page-1/

4 Replies

· Add your reply
  • Sort: 
avatar image
0

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. Feature Set

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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:

https://youtu.be/EaUsHVO_t5M

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

51 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android Share intent Twitter not working? 0 Answers

Share image in Unity Game on Android devices error 2 Answers

NoSuchMethodError when calling putExtra 0 Answers

How should I go about proper GUIText scaling for mobile devices? 0 Answers

Why images in Android project are blurry? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges