- Home /
Android Services running in Unity
Hello,
I currently have an Android Bluetooth service that I have made run in the background to constantly receive serial data from my computer or arduino. This Bluetooth connection will be replaced by a sensor later.
So far, the service is working in Android, but I'm not sure how to start a Service within Unity. I have created some Unity Android plugins before, but those methods are only calling static classes.
Heres the java method that I am currently using to create my Bluetooth service:
public class MainActivity extends Activity {
private static String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startBTService()
}
public void startBTService(){
Intent intent = new Intent(this, bluetoothLibrary.class);
startService(intent);
}
}
Now, in the Unity3D side, I'm not sure how to go about calling non-static void functions.
Any help with my problem would be great.
Thanks
HI phase101, you solve your problem, I had the same situation, I need make a service for listen some events forever... could you fix your problem? how?.
Thanks
Hi phase101, were you able to solve your problem? I was also facing the similar problem.
Answer by SelphFr · Feb 18, 2014 at 02:28 AM
Check http://jeanmeyblum.weebly.com/1/post/2014/02/communication-between-an-android-app-and-unity.html
Answer by musicm122 · Jan 22, 2014 at 03:49 PM
Unfortunately it looks like its not going to be that simple. You would have to build a plugin to communicate between unity and android.
or http://forum.unity3d.com/threads/117723-Application-runInBackground-is-not-working-on-Android for a work around.
I also answered a similar question here