• 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
6
Question by ArmarageX · Apr 20, 2014 at 03:37 AM · androidapprestart

Android App Restarts when "Launched"

Ive recently upgraded to Unity Pro (4.3.4)

I play my game on Android and press the "HOME" button to jump out.

PROBLEM:

1) If i resume the game via the selecting it from the "multitask" button / thumbnail (the button on the right of the HOME button): The game resumes nicely from where i left off.

2) If i resume game by pressing the actual APP icon (which is sitting on the "desktop").... The game restarts!! >.<

I have one android app made using Unity Free, and my new android app made using Unity Pro.

The Unity free 3.x app does not do this, and resumes nicely when i click the APP icon. The Unity pro 4.x app always restarts when i resume playing via the APP icon..

Im probably missing something super simple... but i havent found a solution yet :(

Any solutions would be much appreciated! Thanks!

Comment
Add comment · Show 2
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 _methotec_ · May 21, 2014 at 09:02 AM 0
Share

We have the same issue, could you post your manifest, please? $$anonymous$$aybe together we can figure something out ;)

avatar image kamgru123 · May 21, 2014 at 09:07 AM 0
Share

I had this exact problem when I was using startapp ads. When I switched to another ad provider the problem disappeared.

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by _methotec_ · May 21, 2014 at 03:16 PM

OK.- I found a solution that worked for me. You have to add android:clearTaskOnLaunch="false" to the unity activity in the AndroidManifest.xml If you use a Plugin you already should have a custom manifest - if not you need to copy Unities default AndroidManifest.xml

from: C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androidplayer

to: ProjectFolder\Assets\Plugins\Android

Then modify it like this:

 <?xml version="1.0" encoding="utf-8"?>
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.unity3d.player"
     android:installLocation="preferExternal"
     android:theme="@android:style/Theme.NoTitleBar"
     android:versionCode="1"
     android:versionName="1.0">
     <supports-screens
         android:smallScreens="true"
         android:normalScreens="true"
         android:largeScreens="true"
         android:xlargeScreens="true"
         android:anyDensity="true"/>
 
     <application
         android:icon="@drawable/app_icon"
         android:label="@string/app_name"
         android:debuggable="true">
         <!-- add clearTaskOnLaunch here -->
         <activity
             android:name="com.unity3d.player.UnityPlayerNativeActivity"
             android:label="@string/app_name"
             android:clearTaskOnLaunch="false">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
         </activity>
     </application>
 </manifest>


After the build there is a local copy of the Manifest used in the apk located at ProjectFolder\Temp\StagingArea

An activity can have much more attributes, you may want to look at the docs here

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 M.P.F. · Jun 02, 2015 at 11:07 AM 1
Share

This doesn't seem to solve it for me. Are there any other settings that need to be applied?

avatar image DomRamDev · Dec 22, 2015 at 09:00 AM 0
Share

Thanks man for now it is solving the issue for me

avatar image
0

Answer by gannaz · May 21, 2014 at 11:35 AM

you need a save script that keeps all your previous information (e.g a level game you might be on level 12 and you quit. In your game files located on the phone it will save your previous level)

Comment
Add comment · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

25 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Restart App on iOS and Android 0 Answers

Building an iphone game from a project made on windows? Xcode? 2 Answers

unity Game get restart by pressing home button in android 0 Answers

Asset Bundles Question 1 Answer

Android App crashes suddenly after putting FPS TextMesh 0 Answers


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