Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by phase101 · Sep 16, 2013 at 09:31 PM · androidpluginbluetoothserviceserial

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cmarrero01 · Feb 20, 2015 at 05:28 PM 0
Share

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

avatar image shubhamagarwal003 · Mar 20, 2016 at 12:11 PM 0
Share

Hi phase101, were you able to solve your problem? I was also facing the similar problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

See PluginsForAndroid

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Connect to Bluetooth network within App 0 Answers

Android background app. (idea) 0 Answers

How to make a P2P Unity Android Game 0 Answers

Bluetooth plugin recs for transferring text file from computer to Android app 0 Answers

my in-app purchase is not showing the files 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges