How to use intents with unity google tango

81 views Asked by At

I am currently working with Google Tango and i want to take screen shots and share using native android sharing options. I was able to complete that part but the problem was when the app moves to the sharing intent and when it returns back to the tango app, sometimes the app gets stuck with the "Hold Tight" connection screen.

I am using the following code to share using the native options,

if(!Application.isEditor)
{
   AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
   AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
   intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
   AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
   AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse","file://" + destination);
   intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);

   intentObject.Call<AndroidJavaObject> ("setType", "text/plain");
   intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), ""+ mensaje);
   intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "SUBJECT");

   intentObject.Call<AndroidJavaObject>("setType", "image/png");
   AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
   AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");

   currentActivity.Call("startActivity", intentObject);
}

What am I doing wrong here? why is the app getting stuck with the "Hold Tight" connection screen? Any help would be much appreciated.

0

There are 0 answers