Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Back Button crash during Load

Discussion in 'Android' started by JoshOClock, May 7, 2014.

  1. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    105
    I'm getting a crash when pressing the back button that I can't seem to link to any of my code.

    The only clue I get is this in my logcat:

    I/Unity (17488 ): onPause

    And then it crashes with the "Unfortunately XXX has stopped." dialog on Android.

    Any clues? The back button shouldn't do anything like minimize my app or anything unless I ask it to. Correct?
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    Have you tried to override back button functionality?
    e.g.
    Code (csharp):
    1. void Update(){
    2.   if (Input.GetKeyDown(KeyCode.Escape))
    3.  {
    4.    // Do nothing
    5.   }
    6. }
     
    KeepTrying likes this.
  3. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    105
    I have code like this in various places that bring up popups to exit the game properly. None of these get called in the case that I'm getting my "crash".
     
  4. JamesJwMoon

    JamesJwMoon

    Joined:
    May 13, 2014
    Posts:
    1
    There are so many Unity and Android apps which have same problem. Are those Android problem or Unity problem ? I have similar situation today.
    I got this message.
    " Error finding setting, default accessibility to not found: accessibility_enabled "
    It happens when I come back from Facebook webpage on Firefox using Back Button. When I touch twice, it's OK. Focus back normally. But, I touch more than 3 times, it crashes every time. Have any clue ?
     
  5. Dzxyan

    Dzxyan

    Joined:
    Sep 23, 2013
    Posts:
    165
    why you wanna make it multiple back click?
    you may set some Boolean function to ensure that if button back clicked,
    it just run on time function like this

    Code (csharp):
    1.  
    2.  
    3. bool backClick = false;
    4.  
    5. void Update(){
    6. if (Input.GetKeyDown(KeyCode.Escape))
    7.  {
    8.    if(backClick = false)
    9.    {
    10.    backClick = true;
    11.    // Do nothing
    12.    }
    13.  }
    14. }
    15.  
    16.  
     
    KeepTrying likes this.
  6. KeepTrying

    KeepTrying

    Joined:
    Feb 23, 2011
    Posts:
    119
    @Dzxyan @Agent_007 how do i get this code in .js or can you write the entire set of c# code to this, inluding monoBehavior brackets, using UnityEngine, using SystemCollections and so on ? Thank you!
    Unity 5.1.1f1