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 ?
clear up memory ?
attach an event before-close and on-launch (or on-relaunch) ?
reset APP view to home screen ?
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.
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.
Related
My app uses a pagerTabStrip with fragments. When the app goes to background and other memory intensive tasks run in foreground, the app will be killed. Then, if I recall the app, the fragments buttons onclick methods dont fire anymore. (side note: the color of the buttons is then wrong too, but the "visual click" down->up is working)
It is working fine when I manually kill the app or when it's just short term via onPause/onResume in background. It seems that in this system-kill-case sort of image of the app is taken and reloaded (incorrect).
If there is no direct way to fix this, I would like to catch this event, to just recreate the whole fragment, but I can't. I tried onTrimMemory and investigated the call order of onStop/onDestroy/onRestart ... but I couldnt figure out, when this "special kill" happens.
Thank you!
Got it.
First, to reproduce the issue, just launch the app, send to background and then hit the red circle-cross at the left pane of the logcat output frame in android studio as described here:
https://medium.com/inloopx/android-process-kill-and-the-big-implications-for-your-app-1ecbed4921cb
My workaround is to save the processID in onSaveInstanceState and to check if this changed in onCreate as described here:
https://stackoverflow.com/a/47483856/6053524
If so, the app has been killed by system and my issues of not proper working UI occured. To fix this I load the initial Activity via new Intent/startActivity to get a clean new application.
I'm developing an app for testing purposes for my company. This app receives notifications via GPRS of a remote hardware, that indicates things like if it is On/Off, battery level/ etc...
To make this easy to interpret, I'm using images that represent these states, and these are shown in a fragment. The app has nice visual design, including new desing library features as navigation drawer, etc.
To read received messages from the socket I use a service.
The problem is that, if I have the app opened, everything shows fine, but if I have the app closed, and even the service notifies that something has been received, when reopening the app it's starts in it's default state. So, everytime I close the app (exit from it), it is getting destroyed.
I'm not sure on how could I manage this. The best would be if I could mantain the app running on background, but I think that this can't be done.
So, how could I save the state of the activity, to when I open it again, to have everything like before closing it?
Have you looked at activity life cycle ?
I have an android app which is a wrapper around my mobile site. We have a site that changes everyday, and I’d like to have a method by which I can notify the user that there’s new content to be had, or just reload it programmatically.
This obviously happens when the app relaunches, but sometimes users will keep the app in sleep mode and re-open it the next day and they see a stale version of the website. Is there any way around without going native? One method I thought off was using a push notification to reload the app (i.e. use GCM to tell the app to reload the page) except I don’t want to push a new version as this would require permission changes and that would break auto-updating. I though of using socket.io for the task as I'm already using it in my app but I don’t think it'll work if the app is the background (will it? I’m an android newbie)
Thanks for any help!
When the application returns from sleep - onResume() of the activity life cycle may be invoked. If you reload the webview on this listener, that should resolve it.
Unless i am missing something very significant, this simple solution might work.
I own an android 4.0.3 tablet and I'm programming in Java/SDK, still not tried NDK.
Now, suppose that you want to program this tablet to put it in a service point, with a single use case, like a restaurant, where it would show menus and let the user pass them. I would like not to let the user to shut down this software. Also, it must automatically runs at tablet start up and persisnts on, i.e. if it shuts down by some reason, the tablet should not go back to its standard GUI but to restart this application.
I don't know any start point for this, like some keywords etc. I imagine that here I must code a service (that maintains the persistence and startup of the application) and the application itself.
Could you please give some ideas / keywords / potential start points / comments?
Thank you in advance.
Here some things you need to check:
1.) How to start an application at boot.
2.) How to run a service/thread in background to check if the application is running and if not to start it.
3.) How to deactivate buttons, ie like the "back" button to not exit the app or program a way that the activity never exits with user interference. (That is very bad practice though!) :)
4.) There should be a way to exit the application though for maintenance purposes. Be creative in that one. Maybe exit only with password or something.
I would like to not to let the user to shut down this software so it must persist.
Make it be the home screen.
Also, it must automatically runs at tablet start up and persisnts on, i.e. if it shuts down by some reason, the tablet should not go back to its standard GUI but to restart this application and represent its GUI.
Make it be the home screen.
I am basically looking for the same functionality found in the DevTools (Development.apk) app that comes with the emulator. I am wanting to perform similar testing on an actual device but the DevTools app does not work properly on the device I have so I cannot use it.
I am looking to test in a similar way.
What this does is causes each Activity to be destroyed whenever it leaves the screen, holding onto its instance state just as if the system needed resources and had killed it. (So I can't just call finish)
Is there a way to do this?
Thanks
You can kill your app's process at any time using the DDMS stop button. highlight your application in the list and click the stop sign button. your application will be destroyed like it was killed by the system.
See the stop button in the left pane(Devices) above each device listing: