I have one problem when I close my app under android, it's call the TmyMainForm.destroy, and this can take some time to free everything. The problem is that all dephi apps are with launchMode="singleTask", so still, the app is not fully closed, you can not launch it again. Now I feel that I can simply do nothing in the procedure TmyMainForm.destroy, even don't call inherited. This seam to work in the tests I did but I m afraid that I do not see some problems this can produce like for example crashing the app because one HTTP connection was working and thus producing report, etc..
question: is it acceptable to ignore TmyMainForm.destroy under android? else is there something like halt in android to stop/kill immediately the app ?
Related
We are using intents to switch from one of our apps to another on request, typically a button that is pressed. That way our apps present themselves as a functional unit to the user. We switch back by means of results we hand back.
Recently we implemented a switch that is not triggered by an immediate user interaction, but by an implicit event. When navigating inside one app we use an activity from another app as a drop-in-replacement for some feature in the first app. So the first app sends the user to the second app if it detects that second app is installed.
I realize we have an issue here: if that second app is buggy, crashes, then the first app is broken. Since it switches to the second back again and again without the user being able to alter that behavior. So apparently it makes sense to enable the first app to realize that the second app just crashed. So that it would not switch over next time, although that second app is indeed installed.
This does not work out of the box, since the first app never is informed about the crash of the second app. Instead that app crashes, the OS hint comes app ("Unfortunately XY just crshed") and that's it. The flow never returns to the first app, so there is no return value to evaluate or similar.
So my question is: how can I enable the first app to learn about the fact that the second app just crashed?
I thought about registering a global handler for uncaught exceptions in the second app. That handler would have to somehow signal to the first app that it is currently crashing. Either by sending a specific intent itself (sounds ugly) or by handing back a result (is that possible at all?).
Is there a common practice for this? What is it? What other options exist? Or is that question itself obsolete, since I only failed to see how this is meant to be done?
UPDATE:
Interesting enough I learend that this actually works if the crash in that second app is raised not upon startup but much later ... In that case indeed the first app is in foreground again and is indeed able to detect the crash: the result is "CANCELED" in that case, which is perfectly fine for me.
The the question is reduced to "early crashes" and how this can be handled. Or, the other way round: what is the difference between early and later crashes in that second app?
You technically can't detect that the app crashed, but you can keep something like a "failure counter" in your 1st app. Basically, every time you're about to launch app #2, save a variable in SharedPreferences, something like launchAttempts. You'll want to increment it every time right before you launch app #2, and then decrement it in your onActivityResult() when a result is returned. Then you can set a threshold for how many failed attempts would qualify for "too many", and stop launching app #2
I've been asked to fix an android application which has issues after switching to a newer device. The switch was from android 7/8 to 11. The application opens up google maps for navigation but very often when returned to the app all data is lost, and clicking on anything will reset it back to the startup activity. It doesn't matter which apps it switches between the issue happens with all of them.
I've tried several things:
-Disabling all battery saving options on the device
-Using OnSaveInstanceState to retain the data
-Using a backgroundservice to retain the data
The issue only occurs on actual devices, using an emulator results in no errors.
When the debugger is attached to the application it loses its connection before returning to the app. It is possible to re-attach when returning to the app but it disconnects as soon as
anything is clicked.
And best of all there's literally no error message shown anywhere.
The following comment provided the solution I needed.
You would need to start a foreground service, complete with its Notification. Even that does not guarantee that your process will remain around.
– CommonsWare Sep 1 at 12:40
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.
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.
I have written a simple database program in android. It runs fine, there is no force close error. But I checked from my application from Settings App I see the Force Close option enabled, which implies that my application is still running in the background, even though I have completely came out from my application to the home screen by pressing back key. And moreover I am not using any services, alarm or broadcast things.
Can some one please guide me what may be the probable reason?. Or is it okay? Or will it crash if I put it on device?
Can some one please guide me what may be the probable reason?. Or is it okay? Or will it crash if I put it on device?
Your application is alive until Android OS needs more memory and destroys it. What I have understood does Android start destroying activities before killing the whole application. This means that your application can be alive even if you have finished your activities.
Do not worry about this; Android OS is handling this extremely well.