i need send broadcast message unity3d application running on android device. i've seen tutorial
http://jeanmeyblum.weebly.com/scripts--tutorials/communication-between-an-android-app-and-unity
but need opposite thing. unity app sender , android app receiver. hard obtain?
this code:
1) code created .jar import in unity
package com.example.unitysender; import android.app.activity; import android.content.intent; import android.os.bundle; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); intent intent = new intent(); intent.setaction("unitytoandroid"); sendbroadcast(intent); finish(); } }
2) code in unity, method createinstance public static can call button.
using unityengine; using system.collections; public class mainactivity : monobehaviour { static androidjavaclass jc; // use initialization void start () { } // update called once per frame void update () { } public static void createinstance() { jc = new androidjavaclass("com.example.unitysender.mainactivity"); jc.callstatic("createinstance"); } }
i'm pretty sure it's wrong if can guide me in right direction i'll happy. in advance.
Comments
Post a Comment