I made a metronome app that plays a click sound at whatever beat per minute the user wants. It works fine but on Android as soon as the screen goes to sleep it stops. I want to use the app with headphones, but having the screen on constantly will kill the battery way too quickly.
Is there a way to keep my app clicking away after the screen goes to sleep on my phone?
Thanks for any advice,
TJ.
Keep app running when screen sleeps?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Keep app running when screen sleeps?
Hi,
no idea if it would play the sound when the fone goes asleep, but to keep an app running I do:
This works great on my tablet with plenty of RAM & a very basic (hand-cleansed) Android - the app can run for days easily, even if I use my map (Scout) & my eBook reader (PocketBook), hear music (Clean music) and run others of my apps meanwhile.
This doesn't work on a stock Android phone with tiny RAM & crammed with manufacturer enforced crap, Android will kill the app due to RAM shortage quickly.
So it's just a question of available RAM. And, of course, a question of if Android will play sounds while sleeping at all :)
Have fun!
no idea if it would play the sound when the fone goes asleep, but to keep an app running I do:
Code: Select all
on upDateClock -- in stack script, started at openstack
if the short name of the topstack = the short name of me then
put the abbr system time into fld "clock_fld" -- a small field displaying the time
end if
send "upDateClock" to me in 20 seconds
end upDateClock
This doesn't work on a stock Android phone with tiny RAM & crammed with manufacturer enforced crap, Android will kill the app due to RAM shortage quickly.
So it's just a question of available RAM. And, of course, a question of if Android will play sounds while sleeping at all :)
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
-
- Posts: 18
- Joined: Tue Oct 25, 2016 8:09 pm
Re: Keep app running when screen sleeps?
Thanks for the suggestions, much appreciated. My fone in rooted running CyanogenMod, so no extra crap and 4 gigs of RAM, however I'm wondering how long the battery would last.
I'll have to give it a try and find out.
Thanks,
TJ.
I'll have to give it a try and find out.
Thanks,
TJ.
Re: Keep app running when screen sleeps?
Have a look at mobileLockIdleTimer in the dictionary.
You also have to make sure that Idle Timer is checked in the Android Standalone Settings.
You also have to make sure that Idle Timer is checked in the Android Standalone Settings.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
-
- Posts: 18
- Joined: Tue Oct 25, 2016 8:09 pm
Re: Keep app running when screen sleeps?
Thanks Andy!
I was aware of mobileLockIdleTimer, however won't this keep the screen on?
I'm really hoping for a solution that will allow the app to continue to play sounds with the screen sleeping. My main concern is the huge battery drain of having the screen on the whole time the app is running.
Thanks for your help, much appreciated,
TJ.
I was aware of mobileLockIdleTimer, however won't this keep the screen on?
I'm really hoping for a solution that will allow the app to continue to play sounds with the screen sleeping. My main concern is the huge battery drain of having the screen on the whole time the app is running.
Thanks for your help, much appreciated,
TJ.