Creating an Alarm Clock App for Android Phone / Tablet

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
archer2009BUSknbj
Posts: 72
Joined: Sat Apr 06, 2013 8:09 am
Location: London

Creating an Alarm Clock App for Android Phone / Tablet

Post by archer2009BUSknbj » Tue Apr 23, 2013 8:28 pm

I'm new to LiveCode - only been using it since it went OpenSource.

I thought for practice I'd try and create something useful that I'd actually want to use each day, so I thought have a go at creating a very simple Alarm Clock App that might run on my Android Phone.

Are there any Tutorials, or sample Alarm Clock Apps out there I could look at to try and figure out how they function?

Are there any specific issues to creating an App that runs in the background like an Alarm Clock and then comes alive at the correct time?

I'll be using a Samsung Galaxy Note running Jelly Bean ROM.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5775
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Creating an Alarm Clock App for Android Phone / Tablet

Post by jacque » Wed Apr 24, 2013 6:38 pm

The main problem is that LiveCode apps can't (so far) run in the background. They will stay resident on Android as long as the system doesn't need the RAM, but they can be wiped out at any time so you can't depend on them staying around. To get around that you might be able to use notification services, but I haven't played with that yet and it's probably more advanced than a newcomer should tackle.

To learn though, you could easily make an alarm clock as a desktop app, and I'd encourage you to try it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

archer2009BUSknbj
Posts: 72
Joined: Sat Apr 06, 2013 8:09 am
Location: London

Re: Creating an Alarm Clock App for Android Phone / Tablet

Post by archer2009BUSknbj » Wed Apr 24, 2013 7:28 pm

Well it's ok for now if it can't run in the background

Another reason for choosing an Alarm Clock is it's one of the few Apps I'd prefer to use in Landscape Mode, so I can design the App in Landscape mode which fits on my 1080p Monitor - my Samsung Galaxy Note is 1280 by 800 pixels so anything in Portrait Mode would go off the screen on my PC. I can worry about learning to resize Apps later

But I really have no idea how to go about writing the App in terms of what the commands are and how they work.

I know in my head what I want to do, let the user chose a time, put that time in a variable and when the actual time equals the alarm time then play a sound file.

In the past when I wanted to learn how something worked I'd find something similar that already existed and read through the code, make changes, add and remove sections and learn that way.

I haven't found a similar Alarm Clock App so have nothing to work from. All I have is the dictionary and blindly trying key word searches to try and piece together random commands.

Some of the commands I've found seems to be exclusive to mobile phones such as iphonePickDate command.

Also is there a fast way to transfer APK files to a real mobile phone for testing?

So far I've been saving the APK files to my hard drive and then using AirDroid to install them, when I used MIT Inventor any changes I made on my computer were automatically synced over WiFi with my mobile phone in real time, which was so handy.

I could literally change the color of a button on my PC and within a second it changed on my phone.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Re: Creating an Alarm Clock App for Android Phone / Tablet

Post by sturgis » Wed Apr 24, 2013 8:14 pm

I have a very simple alarm app (desktop only) that you can look at if you like. If you learn best by looking at code it might help. Otherwise, here is a quick synopsis of what my little clock does without any actual code.

My clock is basically 3 fields and a button.

The top field, I can type in a date and time (like 4/26/2013 7:30 AM)
The middle field is just the display of the current time.
The bottom field contains a message that revspeak will say when the time is up.

The first step is to decide how you want to do the time comparisons. In my case, I convert the above date and time into seconds and store it (as you indicated) so that it can be used for comparison.

The button toggles whether the timer is running or not.
If the timer is supposed to be running, I use a send in time loop (send "mytimerhandlername" to me in 1 second) to update the clock and check the alarm time.
During the run of the handler being looped, update the current time, get the current "seconds" and compare it to the stored seconds. If current > than the stored seconds, speak the alarm message 5 times and update the alarm field to show the message "Expired."

It is EXTREMELY plain, no date/time pickers, only a single alarm, but it also happens to work very well for my needs.

If you want to look at the stack let me know and i'll pop it in here.

rwhe
Posts: 16
Joined: Fri Aug 02, 2013 5:52 am

Re: Creating an Alarm Clock App for Android Phone / Tablet

Post by rwhe » Tue Aug 06, 2013 4:00 pm

sturgis, I would like to see your code. Thanks.

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: Creating an Alarm Clock App for Android Phone / Tablet

Post by rumplestiltskin » Fri Dec 05, 2014 12:31 am

Is there a method for blocking all other notifications while this app is running? I'm talking about phone calls and any other app that might utilize sound as a notification?

Thanks,
Barry

Post Reply

Return to “Android Deployment”