Prakash Raman
Prakash Raman

Reputation: 13933

Titanium APP (Android) crashes when brought alive from background

From the beginning of the APP development, I found that if I re launch the APP, the APP crashes and nothing gets displayed. I think it has something to do with the resource that is assigned to the APP and it trying to restore its previous state and it is failing to do so.

I see that, in many APPs, when it re launches the view is reset to its first screen. I would like to do the same in my APP.

Any suggestions on how I should be handling this ?

This is the first APP I am building (happens to be in Titanium). Therefore my fundamentals of APP development are weak.

Any help would be greatly appreciated.

Upvotes: 0

Views: 332

Answers (1)

Martin
Martin

Reputation: 1914

I'm not sure what you are doing in your app, but I'm not seeing that in my Titanium apps. My users probably leave my app running/paused for days and then resume them as needed. Until their device runs out of juice, I'm pretty sure they never restart my app. Perhaps a module you are using?

There are events you can handle that will allow you to take an action when the app is put paused and when it is resumed. You can write your code to reset the app to the starting screen, which I'm partial to that idea as well. I'm not aware of a call you can make that will essentially restart your app.

The events you can handle.

Ti.App.addEventListener('pause', _.bind(this.exit, this));
Ti.App.addEventListener('close', _.bind(this.exit, this));
Ti.App.addEventListener('resume', _.bind(this.resume, this));

You would have to write the action taken when these events happen.

Code is from the https://github.com/appcelerator/Field-Service-App. This app has the hooks, but doesn't implement any actions for them. Check out the alloy.js file.

Upvotes: 2

Related Questions