Dimon
Dimon

Reputation: 11

How i can run unity app in background on Android?

I have a problem, I need my Android app to stay active when it's in the background.

Application.runInBackground = true;

Upvotes: 1

Views: 7705

Answers (3)

ZoDy
ZoDy

Reputation: 41

You can use UnityThread script, I've created Bluetooth low energy plugin that will continue to work within background in a new Thread.

Check this: https://github.com/222ZoDy222/Unity-Bluetooth-Low-Energy-Background-Andoid

  • If you want your application to run in the background, but don't need it to work 24/7, then a new thread is enough for you.
  • If you want to your application play 24/7, you should use Java services as stated above

Upvotes: 3

Nikel
Nikel

Reputation: 126

Android application created by Unity can't run in background. Application.runInBackground is ignored on Android and iOS platforms. In case of Android, Unity app extend Activity class which run only when app in the focus. If you want run something in background you should extend and write logic in Service class. It`s good described here. But for it need to write you own plugin or something similar to this.

Upvotes: 2

SupaMaggie70 b
SupaMaggie70 b

Reputation: 346

From this unity question:

Project Settings, Player, Resolution and Presentation, check the Run in Background option.

Upvotes: -1

Related Questions