Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Home Button destroys App?

NessaNessa DEMember ✭✭

Hey guys
I have an App and I want that when the User pushes the Home Button and then the Task Manager to get onto the App again, it should open where he left.
But that doesnt happen.
When the User is tapping the HomeButton OnPause and OnStop are activated, like it should. But when I go to the App with the Task Manager again He creates my first page again, because in the mainactivity he goes to OnCreate instead of OnRestart or OnResume.
So I think it will be destroyed instead of simply paused or stopped? How can I prevent this?
thank you very much

Best Answers

  • NessaNessa DEMember ✭✭
    Accepted Answer

    Ah and now I foundd out why it got destroyed...
    there's a Setting in the developer Tools named something like actitivty log
    this Setting was activated and so it destroyed every activity, when the user is not using it (or background)

Answers

  • LentoManLentoMan SEMember ✭✭
    edited August 2017

    Perhaps the app is crashing or your device/emulator is running low on memory?
    Check the logs in Android Device Monitor (DDMS).

    Also make sure you aren't doing any accidental cleanups in the OnDisappearing() for your page/view, since that method also called when the app is sent to the background.

  • AlmaJensen.9398AlmaJensen.9398 USMember ✭✭✭

    I think pressing the home button breaks your debugging session so getting a stack trace may be difficult. What I would do is connect your app to Hockey App or I guess is now Windows Mobile Center, there should be some crash reporting that you can register and hookup in your app that will give you a stack trace to help you figure out what's really going on that's crashing your app.

    If you have access to Xamarin Insights it does a really good job of this. Sadly it has been deprecated though and access is limited now to accounts that had already been using it.

    I would try Hockey App or I guess is now Windows Mobile Center as it's supposed to replace Xamarin Insights. But if you still can't get that to work get with me later and I can see if I can help you figure this out.

  • NessaNessa DEMember ✭✭

    I can debug it on my device even after it gets destroyed. So I know that after clicking the home button the app is ondestroy and if i then open it again with the Task messeger it goes to oncreate (of course... thats how it should go ofter destroy... my prob is that it destroys T.T)
    I have read that the only possibility is then that the System kicks it out because it Needs too much RAM but I looked it up and my App only Needs like 50 MB and android is kicking it out even though there are greater apps and controlls

    So for the ondisappearing... in there stands nothing that would delete everything

    But I have an new Idea to half way solve my Problem
    Can I put a Parameter/Variable or stack or some activity like saving where it will be saved on which page the user was before closing my app? i mean then i could write something in oncreate so that the right page will be loaded
    BUT how can I make such a variable? because after ondestroy everything is gone? I cant really save it, can i ?

  • NessaNessa DEMember ✭✭
    Accepted Answer

    Ah and now I foundd out why it got destroyed...
    there's a Setting in the developer Tools named something like actitivty log
    this Setting was activated and so it destroyed every activity, when the user is not using it (or background)

Sign In or Register to comment.