Jump to content
  • Advertisement
Sign in to follow this  
zatokar

Unity Android run in background

This topic is 851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am building a simple game where 2 people can duel against each other. I am using GameSparks as a back end. My problem is, that whenever player #1 casts a spell that is channeling, player #2 can see the channeling only when his screen is turned on and in focus.

 

Whenever player's #2 screen turns off, the app is not active anymore so the spell is not being casted at him. When player #2 turns on the screen, the channeling starts, but player #1 was already done channeling a while ago.

 

I assume that is related to the way Android system works. It puts apps that are not in focus on pause.

 

My problem now is, how can I make sure that player #2 gets a notification whenever he is hit by the spell without a need to use any third party service to keep the app alive (to avoid huge battery consumption) and also without a need to use push notifications (as from what I've heard, if there is a high load, the push doesn't happen right away, since there is a queue)

 

Share this post


Link to post
Share on other sites
Advertisement

Android apps can create a "persistent notification" in the notification bar.

I would suggest that you use the notification system to display a "so and so is casting a spell" notification while that's happening if the app is in the background.

Separately, Android allows you to start Services, which can run in the background and communicate with servers, without having the same aggressive suspension as UI-facing activities.

This can be used for things that need to communicate while the app is in the background. However, don't abuse Services to do things like continually run a game update loop -- that will drain the battery very fast!

Share this post


Link to post
Share on other sites

Hi Zatokar,

Have you updated to the latest sdk? What version are you running? If you log a ticket with our support team over at GameSparks we can get this issue resolved for you. Additionaly, if upgrading to the latest sdk doesn't solve this, you could set up custom messages and listeners to notify the client when certain events are fired.

Best Regards, Patrick. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!