i just create a game and when user press home button in his/her android mobile, the game goes into background and it is in a running phase with OnApplicationPause() method, now if game is not come in foreground from background in 10 seconds i want to kill the game from memory, so the game will not eat the battery of the user. so is there any way to do that please help
You can’t do that without some native code which runs a seperate background thread for this. An app, once it looses focus, is actually paused and doesn’t execute any code. Only background services do that. Assuming you talk about Android: the Android OS manages it’s memory automatically. If an app is in the background it might be killed automatically if the OS needs the memory. Apps in the background are not guaranteed to stay there.
As others have mentioned above, an app in the background does not require any processing power at all as the app is completely paused.
So it doesn’t make much sense to implement something like that. It also will annoy users which had to take a break for 1 or 2 minutes because the received a call or something else and when they come back the game will restart.