Question

I have a small script, that functions as a broadcast receiver, and which I have programmed in Python (the script hands off processing to another main Python program). I don't know Java. In order for the receiver to function, however, SL4A naturally needs to keep running. As far as I can see:

  • SL4A does not hold a wakelock (which is not required for a broadcast receiving script anyway); no wakelock is indicated by GSAM Battery Monitor unless I explicitly acquire it with the wakeLockAcquirePartial (or whichever wakelock I need) API call. Hence it should not run down the battery too much.
  • Though it is described as "alpha quality" software, in a discussion in 2012 it was felt that SL4A was stable enough for the play store, and this option was only rejected because of the potential security problems involved in giving one app so many permissions.
  • I have seen SL4A crash, but that usually seemed to be the result of the script in question (e.g. not releasing a wakelock properly).

Given this, are any problems likely? I should note that the phone in question is not going to be used much for calls etc.

Was it helpful?

Solution

I ran an application with more than 3 threads for hours in daily use without a problem. But I used the method to turn the script into a standalone APK. This method can be found in the SL4A FAQ.

OTHER TIPS

I've now been using this system for over two months, and just wanted to share my experience in case it may be of use to anyone else.

Using SL4A to run a broadcast receiver script works well - but only for about two to two and a half days. Then SL4A inexplicably appears to stop (no exception is thrown, at least within my script). I have not succeeded in running SL4A for more than three days continuously. I should mention that the phone is a Samsung Galaxy Star.

I managed to set up a system to autorecover from such situations by having my script grab a socket using a slightly modified version of the code given in this answer and hold it when running. Every ten minutes another script is started by TaskBomb and tries to grab the same socket. If it succeeds, it relaunches the original script using the launching code given here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top