Anyone developing apps for Android that are run all the time?

Started by dave-at-axon, May 05, 2014, 01:38:17 PM

Previous topic - Next topic

dave-at-axon

Is anyone using the A20 to run an app 100% of the time and never stop and must remain in the foreground?

I've run into an issue with this. Android doesn't like you doing this and after about 10 hours continuous running, my app was closed by the OS. That's not ideal for a system that's being developed for remote monitoring.

I've just made a wee change to add an always visible notification in the task bar as I read that Android does not close down apps that are doing this. Fingers crossed but it will be some 10 hours or more before I know.

In the meantime, I am digging through the Android source to find where it does this and hopefully I can bypass this behavour as part of my custom build.

I am wondering how some of the media player apps for the Google TV etc get around this issue?

By the way, a partial wakelock does not work either. After about the same time, I got an error in logcat saying my app had held the wakelock too long! :(

jess

Now that's something - kind off like the in-famous memory leak in WIN98 :)

dave-at-axon

I don't think it has anything to do with memory leaks. The GC output seems pretty constant.

I have found a way around it though. Putting a notification icon in the task bar and set setOnGoing(true) prevents Android from closing down the application.

sacherjj

I don't recall the exact flags, but in the AOSP you can configure an app to be persistent.  The one that is generally a good example is the phone app.  This flag or setting (not remembering exactly how I played with this over a year ago) tells Android that it needs started an kept started.  Even if you kill the app, the system will restart it.

I would look at something like that so Android keeps it running for you.  I'm not remembering if Karim Yagmour covers this in his Embedded Android book.  I know he mentioned it during one of his talks at AnDevCon in 2013.

dave-at-axon

I've gotten it to stay running by using the permanent notification ICON trick that apps like BBM use.

The app now has been running and uploading to a SCADA system for over 7 days now without any issues.

I've got that book so I might look through it on my flight tomorrow :)