Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by siddharth3322 · Aug 10, 2014 at 05:52 PM · iossocialsharingandoid

Share text message on selected media

I want to share text data on player selected social media. Basically I want to implement functionality like following link represent for android.

Send Text Content

I want to give user a choice for sharing on Twitter, Facebook, Messaging, Gmail etc. Above link give proper guidance for my question.

Here is code that work on android

 Intent sendIntent = new Intent();
 sendIntent.setAction(Intent.ACTION_SEND);
 sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
 sendIntent.setType("text/plain");
 startActivity(sendIntent);

I don't know same functionality implementation in Unity. Basically at present I am targeting two platform for my game

  1. Android

  2. iOS

Now I think my question is clear to all of you. So please help me to solve it.

Comment
Add comment · Show 4
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 siddharth3322 · Aug 13, 2014 at 12:36 PM 0
Share

I need some help for this. I only want to know, In Unity, Can I able to core android code?

avatar image fffMalzbier · Aug 14, 2014 at 08:32 AM 0
Share

This should get you started on running your java code form unity http://docs.unity3d.com/$$anonymous$$anual/PluginsForAndroid.html

avatar image siddharth3322 · Aug 19, 2014 at 08:40 AM 0
Share

I am looking for similar answer for iOS. Anybody know about this.

avatar image uwasimu · Apr 15, 2015 at 05:34 AM 0
Share

here is the code for screen shot but i need for text

AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); intentObject.Call("setAction", intentClass.GetStatic("ACTION_SEND")); AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); AndroidJavaObject uriObject = uriClass.CallStatic("parse","file://" + destination); intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_STREA$$anonymous$$"), uriObject); //intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TEXT"), "testo"); //intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_SUBJECT"), "SUBJECT"); intentObject.Call("setType", "image/jpeg"); AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = unity.GetStatic("currentActivity"); currentActivity.Call ("startActivity", intentObject);

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Mayank Ghanshala · Aug 18, 2014 at 01:01 PM

Dont know for IOS but for android you can..

 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"), "This is my text to send.");
         AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
         AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity");
         currentActivity.Call ("startActivity", intentObject);
 
Comment
Add comment · Show 6 · 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 siddharth3322 · Aug 19, 2014 at 03:28 AM 0
Share

Thanks @$$anonymous$$ayank, I will check it and reply you shortly. For above code, where I have to write it?

avatar image Mayank Ghanshala · Aug 19, 2014 at 07:52 AM 0
Share

in your script . write them in a method and call it on your share button click. Actually AndroidJavaClass is used to access android methods in unity. You can find more on this.

avatar image siddharth3322 · Aug 19, 2014 at 08:39 AM 0
Share

Thanks for your answer. It works for android.

avatar image Mayank Ghanshala · Aug 19, 2014 at 08:48 AM 0
Share

Welcome any time. I don't know about IOS but if I will find I will paste here soon.

avatar image uwasimu · Apr 14, 2015 at 09:13 AM 0
Share

its not working for android i want to share text but its not working... if i want to share screen shot its working

Show more comments

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

25 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

Related Questions

Executing native iOS code in Unity 1 Answer

Share image on selected media 1 Answer

A node in a childnode? 1 Answer

Game Center login windows popups after hiding an app 0 Answers

Why a 109kb .png file teakes 8mb in unity? 1 Answer


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