x


Android - launching an app just after quitting it

Hello,

I created sample application using Unity trial, deployed it to my Android phone and launched. It works ok, but when I quit it (Application.Quit()) and try to instantly relaunch it, touching the app icon causes screen refresh only (all icons disappears and are back in a fraction of second). The second touch launches application again. But, if I wait a few seconds after quitting, touching app icon works as supposed - app is launched.

I believe this issue is not related to my specific game, because I observe the same behavior for official Angry Bots downloaded from Google Play.

Is this an expected behavior?

Btw - my phone is Samsung Galaxy S2, Android 2.3.3

more ▼

asked Aug 11 '12 at 08:11 AM

ArkaneX gravatar image

ArkaneX
3 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

This is expected, since you are not advised to manually shut down apps(the OS determines the proper time to shut the app down). Its not a unity problem, or problem in the OS..just how it works.

more ▼

answered Aug 11 '12 at 09:29 AM

OperationDogBird gravatar image

OperationDogBird
1.1k 1 8 15

I take your point, though there are many application not following this rule and pressing back just quits these apps instead of moving them to background. Even some Google apps behaves like this, e.g. Maps or Sky Map. So it definitely is some issue related to how Unity works (or maybe Mono).

Anyway - what should be the proper way of handling back button then? I.e. I launch a game, press back and want to be taken out of the game, which should be in the background now. As far as I know, there is no such possibility in Unity SDK. Or hopefully I'm missing something...

Aug 11 '12 at 11:27 AM ArkaneX

Processes will be quit, whereas apps should not. I know there are games that dont follow this rule, and that may be what you want to do..not sure if your app will be rejected for hard quitting your app tho(i know iphone has strict rules about not using this functionality).

Heres a portion of an article explaining why killing an app isnt exactly doing any good:

"It's actually possible that this will worsen your phone's performance and battery life. Whether you're manually killing apps all the time or telling the task killer to aggressively remove apps from your memory, you're actually using CPU cycles when you otherwise wouldn't—killing apps that aren't doing anything in the first place."
Android Task Killers

As far as i know there is no ReturnToHomepage type functionality. You can write a plugin that does this using the following native code

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Aug 11 '12 at 07:26 PM OperationDogBird

Thank you for all the information and for providing the snippet. Now I have to consider which path to follow, but I guess I'll stick to Application.Quit() - if Angry Birds and Temple Run (made in Unity) can successfully use it, then I believe I can too ;)

Aug 11 '12 at 08:01 PM ArkaneX
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2489

asked: Aug 11 '12 at 08:11 AM

Seen: 308 times

Last Updated: Aug 11 '12 at 08:01 PM