daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void ShareAndroid(string body, string subject, string url, string[] filePaths, bool chooser, string chooserTitle)
  2.     {
  3.         AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
  4.         AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
  5.  
  6.         intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
  7.  
  8.         AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
  9.         AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + filePaths[0]);
  10.  
  11.         intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
  12.         intentObject.Call<AndroidJavaObject>("setType", "text/plain");
  13.         intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TITLE"), "Color Shoot");
  14.         intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
  15.         intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), body);
  16.         intentObject.Call<AndroidJavaObject>("setType", "image/png");
  17.  
  18.         AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  19.         AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
  20.         if (chooser)
  21.         {
  22.             AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, chooserTitle);
  23.             currentActivity.Call("startActivity", jChooser);
  24.         }
  25.         else
  26.             currentActivity.Call("startActivity", intentObject);
  27.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top