Unity calls the Android method on the web there are many, here is not to repeat, but when we call ANDROIDSDK, is generally inherited unityplayeractivity, and then we start from the mainactivity of our SDK.
So the question is, how do we execute our SDK without modifying the Java file If we have already added Unity's SDK and it has inherited unityplayeractivity?
Idea: Get the Unityplayeractivity class in C # and pass it as a parameter into the method.
1 Unity:2 ```3Androidjavaclass Unity =NewAndroidjavaclass ("Com.unity3d.player.UnityPlayer");4Androidjavaobject unityactivity = Unity. Getstatic<androidjavaobject> ("currentactivity");5 using(Androidjavaobject Jo =NewAndroidjavaobject ("Com.klondike.solitaire.spider.Classic.SDKBridge"))6 {7Jo. Call ("Plugincall", unityactivity);8Debug.Log ("Call the Android method");9 }Ten Java: One Public voidPlugincall (activity activity) A { -LOG.D ("Plugincall","callalllll"); - } the - this way, you can start the relevant SDK directly without having to modify it in Mainactivity - ``` - Android Terminal + ``` - Mainactivity.java + Public voidshowmsg (Activity activity,string msg) A { atIntent Intent =NewIntent (Activity.getbasecontext (), HelloWorld.class); -Intent.putextra ("type", msg); - activity.startactivity (intent); - } - - Helloworld.java in Public classHelloWorld extends Activity - { to @Override + protected voidonCreate (Bundle savedinstancestate) { - super.oncreate (savedinstancestate); the //Setcontentview (r.layout.activity_main); * //TextView showmsg = (TextView) Findviewbyid (r.id.android_show); $String type = This. Getintent (). Getstringextra ("type");Panax Notoginseng //showmsg.settext (type); - } the } +```
Unity adds multiple Android SDKs to resolve conflicts