Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Triss211 · Oct 03, 2013 at 02:45 PM · androidunity-android

How to prevent Android from killing my Unity app ?

Hi. I'm developing an augmented reality app where users can shoot a photo with their mobile device to add 3D objects on it. The problem is that on Android, when the user choose to shoot a photo from my app, the app is put on the background and often closed instead of being kept in memory to handle the photo taken. I know it is because of Android killing apps to free ram.. But is there a way to prevent the killing of my app ? Even on Ipad 2 with its 512Mo of ram IOS doesn't do this brutal killing thing : after the shooting it goes back smoothly to the app. Whereas Android does it with my 1Go of ram phone.

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gamegineer · Oct 03, 2013 at 02:57 PM 0
Share

On the phone settings under "Developer Options" there's an "Apps" section with the checkbox "Do not keep activities". That's not checked by chance?

avatar image Triss211 · Oct 03, 2013 at 03:01 PM 0
Share

No. And I tried to change the limit from standard to 4 running process, and it's not working better. I wonder if I ran my Unity app as a service it would be less likely to be killed.

avatar image Gamegineer · Oct 03, 2013 at 03:41 PM 0
Share

Did you run "adb logcat" and check if the app simply crashes when backgrounded? The logcat should have an entry if it crashes or system closed it, otherwise app exiting on its own.

avatar image Triss211 · Oct 03, 2013 at 03:59 PM 0
Share

Well the app doesn't crash the system kills it to free memory : it's in the logcat and also more my app takes ram more it is likely it is killed by Android when I shoot a picture

avatar image hui xiong · Dec 24, 2013 at 08:16 AM 0
Share

I also meat this problem,Do you resolve now?

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by venusboysatish · Oct 03, 2013 at 05:16 PM

The only way to stop android from killing your apps is to reduce the memory footprint of your game. I don't believe you can override this core android behavior. If the app takes up more than 50 MB (roughly) , android will kill it when paused. use the profiler to see if you are crossing that limit. If you do cross 50 MB, one simple way of avoiding the high memory usage is to load and unload texture data of your assets dynamically. this will require some coding. Look up Resources.Load and Resources.UnloadAsset functions. make sure you do the loading and unloading of assets in couroutine functions.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Triss211 · Oct 03, 2013 at 05:55 PM 0
Share

Thanks for your answer. So I assume if I run my app on a 2Go ram tablet the process will be killed too ? (it surely uses more than 50$$anonymous$$B of ram sometimes) I find that 50$$anonymous$$B limit weird : new phones are getting more and more ram and can handle pretty heavy ressource consu$$anonymous$$g apps.. sad that multitasking is so limited. They should consider to add a swap partition on Android phones with a lot of drive memory.

avatar image venusboysatish · Oct 03, 2013 at 08:16 PM 0
Share

i am not too sure about the 50 $$anonymous$$B limit and how it behaves on a phone with 2 gb ram. its just that in my experience of making 2 games, when tested on android devices with 512 $$anonymous$$B ram, our games were getting killed if the memory consumption is little over 55 $$anonymous$$B, we managed to reduce that to 45 $$anonymous$$B, and the games were not getting killed. i strongly suggest you use the afore mentioned functions to trade cpu power for memory foot print.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Export & Install APK on Android 5 Answers

Read Phone Info From Editor? 0 Answers

Bugsense in unity(android) 1 Answer

Unable to merge android manifests Google Play Games Services 23 Answers

Minimum Api 19 not shown for Android 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges