Android threading issues due to background processes

I wrote a very simple game with some simple animations, but I noticed that when the phone checks emails or several other applications, the animations that update in my stream begin to behave slowly or intermittently.

This is a problem because the game mechanic requires some careful timing on the screen based on the animation. Therefore, if he starts to behave erratically, the game doesn’t actually work well - and it’s not very fun.

Is there any way to prevent this? Can my threads take precedence when they need to start?

+3
source share
3 answers

. android:

mThread.setPriority(Thread.MAX_PRIORITY)
+3

, Android, , -, , , Thread:

Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_DISPLAY);
+2

If you switch to the phone / or some other application during the game, stop your game. Check out the basics, such as wasteful "newbies" of things, unnecessary things. As a last fix, you can do some drawing with a GL context.

Hope this helps :)

0
source

Source: https://habr.com/ru/post/1735970/


All Articles