Locking a Card for a specific time slot & Reminding the user

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Flo92
Posts: 16
Joined: Fri Jul 21, 2017 7:15 pm

Locking a Card for a specific time slot & Reminding the user

Post by Flo92 » Fri Jul 21, 2017 7:34 pm

Hi!
I'm pretty new in LiveCode and I tried to find a solution in this forum but didn't find one in an old topic. I hope I didn't miss something. But first of all excuse my bad english. I'm not a native speaker.
I'm a dentist and I'm developing an app for my doctoral thesis. My app is a survey after a specific treatment. The answers get uploaded on my server and I can interpret them after that.
What is the important part in my app, is that I want the app to remind the user at a specific time that he has to answer my questions. When he gets reminded the user has 2 hours to answer the questions, otherwise it isn't possible anymore and he has to skip this round. All in all he has to answer the questions 10 times over a week.
If he still opens the app (outside this specific time slot) he shouldn't be able to answer the questions as the survey-card is locked.

So what I'm looking for is:
1) A reminder that pops up on the screen of the user just like an alarm clock, maybe additionally in the status bar.
2) Locking the card outside this specific time slot - and in those 2 hours that the user is able to answer the questions

Thank you so much in advance and please excuse my bad english.

Klaus
Posts: 13820
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Locking a Card for a specific time slot & Reminding the

Post by Klaus » Fri Jul 21, 2017 8:34 pm

Hi Flo,

1. welcome to the forum! :D

2. YWe may know each other from the german forum, I gave an answer to your last question.

3. I do not develop for mobile, I don't even own or need) any mobile device, just an old iPod Touch :D
So i canot be of any help on specific mobile tasks, only LC in general, but this is a busy forum and
someone will surely chime in here soon!


Best

Klaus

P.S.
Dein Englisch ist super!

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Locking a Card for a specific time slot & Reminding the

Post by bogs » Fri Jul 21, 2017 10:06 pm

First, I'd agree with Klaus, your english is very good, probably better than mine :)
Flo92 wrote:So what I'm looking for is:
1) A reminder that pops up on the screen of the user just like an alarm clock, maybe additionally in the status bar.
2) Locking the card outside this specific time slot - and in those 2 hours that the user is able to answer the questions
I also do not develop for mobile, but if I were trying to accomplish these tasks specifically, I would probably use the date function (dictionary) to save the time and date the application were opened for the first time (check for the file in the preOpenCard or preOpenStack, if it exists then read it in, else write it out), either to a stack file, or a preferences (plain text or binary) file.

I know that specialFolderPath works on mobile and other devices, so it could be used to save this pref file, where you could then read it in and compare the dates opened after words against the original date, setting up reminders for each goal your looking for generically using a case/switch statement and comparing it to the date read in.

I hope this helps you, if not I am sure as Klaus mentioned others will chime in :)
Image

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

Re: Locking a Card for a specific time slot & Reminding the

Post by jacque » Sat Jul 22, 2017 7:22 pm

Flo92 wrote:So what I'm looking for is:
1) A reminder that pops up on the screen of the user just like an alarm clock, maybe additionally in the status bar.
2) Locking the card outside this specific time slot - and in those 2 hours that the user is able to answer the questions
There's no good mechanism on Android to put up an overlay over another app. If your app is running you can, of course, show a dialog or a group to notify the user.

LC does have built-in notification capability though, which will put a notification into the status bar whether your app is running or not. You have a choice of remote or local notifications; all you need in this case is local which is much easier to implement. See "mobileCreateLocalNotification" in the dictionary. It includes a time parameter, so you'd calculate a 2-hour future time and set the notification to that. When the notification fires, it will send a message to your app "localNotificationReceived" which you can act on.

You could use that message to "lock" the card. There are probably a number of ways to do that, but maybe one of the easiest is to put all the card controls into a group and disable the group when the notification event arrives.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Locking a Card for a specific time slot & Reminding the

Post by bogs » Sat Jul 22, 2017 8:43 pm

Now that is pretty slick.
See Flo? We told you someone who knows would pop in :)
Image

Flo92
Posts: 16
Joined: Fri Jul 21, 2017 7:15 pm

Re: Locking a Card for a specific time slot & Reminding the

Post by Flo92 » Mon Jul 24, 2017 7:52 pm

Thank you so much already! I'll try this out tomorrow. If I'm having any problems I'll definitely come back. Great community here :)

Flo92
Posts: 16
Joined: Fri Jul 21, 2017 7:15 pm

Re: Locking a Card for a specific time slot & Reminding the

Post by Flo92 » Thu Jul 27, 2017 9:59 am

Ok So I tried it with the mobileCreateLocalNotification-Code. The code itself works pretty good and also acting up on the localNotificiationReceived works.
BUT: When the LocalNotification (for example in 180 seconds) is sent and I turn off the device and turn it on again, the LocalNotification seems to be deleted.

Is there any possibility to avoid that? So that LocalNotification works here?

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

Re: Locking a Card for a specific time slot & Reminding the

Post by jacque » Thu Jul 27, 2017 6:40 pm

If the phone is sleeping the notification should persist. But if you power down and then restart, I think the OS clears all notifications (but I'm not sure.)

Edit: I just checked, and yes, Android deletes notifications after a restart.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Android Deployment”