- Home /
Question by
Guy-Corbett · Feb 10, 2018 at 08:56 PM ·
animationandroidshareandroidjavaobjectintent
NoSuchMethodError when calling putExtra
Hi all,
I am trying to construct an android intent and am getting a NoSuchMethodError when I call the putExtra function.
This is the text of the error;
java.lang.NoSuchMethodError: no non-static method with name='putExtra' signature='(Ljava/lang/String;L[Landroid.os.Parcelable;;)Ljava/lang/Object;' in class Ljava.lang.Object;
However, if I am reading it correctly, a function with that signature has existed for ages. Any idea what I could be doing wrong?
My code looks like this;
AndroidJavaObject finalIntent = intentClass.CallStatic<AndroidJavaObject>("createChooser", targets[0], "Share via...");
AndroidJavaClass parcelableClass = new AndroidJavaClass("android.os.Parcelable");
AndroidJavaClass arrayClass = new AndroidJavaClass("java.lang.reflect.Array");
AndroidJavaObject arrayObject = arrayClass.CallStatic<AndroidJavaObject>("newInstance", parcelableClass, targets.Length);
for (int i=1; i<targets.Length; ++i) {
arrayClass.CallStatic("set", arrayObject, i, targets[i]);
}
finalIntent.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_INITIAL_INTENTS"), targetsArray);
Comment
Your answer
Follow this Question
Related Questions
Android Share intent Twitter not working? 0 Answers
Open Android App from URL 3 Answers
Android Share text and image? 4 Answers
Passing parameter from native android 2 Answers
Read intent from Android Studio in Unity 0 Answers