Skip to main content

how to stop the user from quitting the app android



My application sends an sql insert query everytime the telephone is tilted at more than 45°





I need either to stop the user from quitting the application or have it still running in the background so that it still sends the queries





basically I need the application to be running all the time, any ideas? thanks


Comments

  1. One thing is for sure - do not prevent the users from quitting the application. There is, however, a wakelock that can keep the processor on despite being out of the app, using the wakelock flag PARTIAL_WAKE_LOCK. Look into services and wakelock.

    Look here for more information on PowerManager and WakeLock, and here for more information on Services. This link is also pretty helpful regarding a demo on how to use a Service, and this StackOverflow question displays how to properly setup a WakeLock (although you'd want to replace SCREEN_DIM_WAKE_LOCK with PARTIAL_WAKE_LOCK for your purpose).

    ReplyDelete
  2. You should create a Service. This will run in the background executing the SQL inserts while leaving the user free to interact with their phone and answer calls. Remember to keep in mind battery usage and CPU resources while it is running.

    Another common technique is to add a status bar notification while the service is running. This informs the user that the app is still running in the background, and allows them to bring a relevant activity back to the foreground by selecting it.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?