- Home /
Question by
fusecore · Aug 02, 2015 at 10:56 PM ·
androidjavanativeandroidjavaobject
How to translate ArrayList to C# using AndroidJavaClass?
I'm trying to convert this code from java to C# calling java classes.
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
ArrayList<Uri> files = new ArrayList<Uri>();
files.add(bmpUri1); // uri of my bitmap image1
files.add(bmpUri2); // uri of my bitmap image2
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
I have it working for a single image in the code snipped below. But I want to submit multiple images to the Intent.
string filePath=Application.persistentDataPath+"/" + (advInt) +".1.png";
AndroidJavaClass intentClass = new AndroidJavaClass ("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject ("android.content.Intent");
AndroidJavaClass uriArrayListClass = new AndroidJavaClass();
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse","file:" + filePath);
intentObject.Call<AndroidJavaObject> ("setAction", intentClass.GetStatic<string> ("ACTION_SEND_MULTIPLE"));
//intentObject.Call<AndroidJavaObject> ("setType", "image/png");
intentObject.Call<AndroidJavaObject>("putParcelableArrayListExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity");
currentActivity.Call ("startActivity", intentObject);
But the problem is that I do't know how to translate an arraylist of Uri to AndroidJavaObject/class. Could anyone help?
Comment
Your answer
Follow this Question
Related Questions
NoSuchMethodError calling android method 2 Answers
Can't access android mediastore 1 Answer
Using AndroidJavaObject properly 1 Answer
AndroidJavaObject.Call fails with 'method not found' 1 Answer