Alarm clock using B4A

ribber

Member
Licensed User
Longtime User
Hi @all,

did someone of you already created an alarm clock event using B4A. For example I want to create an alarm at 7.00 PM. I know about the possibility using services and timer but I want to create a real alarm in the android OS.

Thank you.
 

wmardian

Member
Licensed User
Longtime User
Dear Mahares,
Many thanks for your help. If it worked in your dev environment, it must be my B4A installation or my phone does not work well for the service. I use rooted lenovo P780 with jelly bean. And the B4A version 3.20.

Anyway,
1. is it correct structure to create a service app ?
2. Do you have any idea what should i check to make sure the IDE installation is correct?

thanks in advance
best regards
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Mahares,
Finally i can run the simple_alarm app. After put Service_Start (StartingIntent As Intent) as per Erel said.
BUT
I still can not run my test app. When i clicked the button, there is nothing happen :(

Best Regards
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Erel thanks. I already try to run but still no luck. When i click the button, the notification does not show up, and also the toast message does not show either. Anyway thanks, i will try to make another project just to test it. (fyi- when i try to run simple_alarm app from susu, it works)

Rgds
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Erel, Mahares and all users,
Can you please help to see these 2 source code? I can not spot the different in term of the code that made the "weker" app does not work.

These 2 are basic app for service, the "alarm" is modified version of susu's simple_alarm, this one work well.
But when i create another project in my IDE, and copy the code, but with the different variable name, the app "weker" does not work. The notification does not show up. When i click the button, there isn't anything happen.

It is really confusing, to know "service module" can not work well in my IDE and my phone if i create from scratch.
Your help is veru appreciated.
Thanks and Regards
 

Attachments

  • alarm.zip
    236.3 KB · Views: 553
  • weker.zip
    7.4 KB · Views: 403
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Dear wmardian:
I tested both of the projects you posted with B4A 3.50 and in legacy mode on a Samsung galaxy tab2 7 inch and both work very well as designed. I did not see any problem. Perhaps you can test on another device or someone else can test them and disclose their findings.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i tried weker on samsung galaxy note 3 in release-mode. put some logging into the code and gave the buttons text... it works for me here.
but i changed
B4X:
StopService(wekerService) 
CancelScheduledService(wekerService)
with
B4X:
CancelScheduledService(wekerService)
StopService(wekerService)

It works fine here...
What problem do you have with it?
 

Attachments

  • weker.zip
    7.7 KB · Views: 423
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Don,
Many thanks for your effort trying to debug the app. Let me download and test it. Are you sure changing the order of the stopService and cancelScheduleService has the effect?

Thanks in advance
best Regards
 
Upvote 0

wmardian

Member
Licensed User
Longtime User
Dear Erel, Mahares, DonManfred and all B4A users..
Thanks for your help in this forums, finally i know the cause of this issue..

It is the package name. After i change the package name, the service app run well. I have no idea what's wrong with it BUT, after changing the package name to something else (not B4A.example), it can RUN.

Thanks again :)
Best Regards
 
Upvote 0

delozoya

Member
Licensed User
Longtime User
Hello! I use this code in service
B4X:
Sub Service_Start
'mp.Initialize()  'Initialize Mediaplayer
'PlayAlarm
Main.noti.Cancel(1)
        noti.Initialize
        noti.Light = True
        noti.Vibrate = False
        noti.OnGoingEvent = True
        noti.Sound = True
        noti.Icon = "icon"
        noti.SetInfo("Alarm", "Apagado", "")
        noti.Notify(2)

                EjecutarRoot("settings put global airplane_mode_on 0")
        EjecutarRoot("am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false")
'ToastMessageShow("Hey!!!! Wake up!!!", True)
End Sub

It works perfectly(wake up correctly), but when I get to this part of the code does not do me until you unlock the device

B4X:
        EjecutarRoot("settings put global airplane_mode_on 0")
        EjecutarRoot("am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false")
End Sub
 
Upvote 0

Startup

Active Member
Licensed User
Longtime User
I wrote a simple alarm base on Erel's code. Hope it can help :)
The "simple alarm" that susu wrote works great but when I try to recreate it by copying the code to a new main module and load susu's layout to the designer and add susu's alarmservice module I don't get the same input gadget. The gadget I get does not show the + and minus buttons to set the time. What am I missing and how can I get the same time setting gadget that shows in susu's app? Here is my zip file. Thanks!
 

Attachments

  • AlarmTest.zip
    8.8 KB · Views: 424
Upvote 0
Top