ebasic Member Licensed User Longtime User Feb 13, 2017 #1 Hello there I´ve got a question Let´s say I have a timer (Timer1) and a label (lblCountdown) and a button (btnStart) and the situation is the following: 1. open the app, timer is initialized Code: Copy Timer1.Initialize("timer1",1000) 2. click the start button, timer1 is enabled Code: Copy Sub Button1_Click Timer1.Enabled=True End Sub The code goes let´s say: Code: Copy Sub Timer1_tick Label1.text=Label1.text+1 Dim n As Notification n.Initialize n.Vibrate=False n.Sound=False n.Icon = "icon" n.SetInfo("CountDown", Label1.text, "") n.Notify(1) End Sub Now when the counter counts up to 10,20, 60 or anything I set up I would like to play a sound, beep or anything, which it also does - IF the app is in foreground and IF the screen is ON(Sure I can set the screen to be awake inapp), the thing is as soon as I open a new app(messaging etc) the counter app doesn´t play sound or beep as soon it reaches 10,20,60. I´ve tried to solve it with service but the best I achieved is to put app in foreground as soon I open any other app. Thank you very much Last edited: Feb 13, 2017
Hello there I´ve got a question Let´s say I have a timer (Timer1) and a label (lblCountdown) and a button (btnStart) and the situation is the following: 1. open the app, timer is initialized Code: Copy Timer1.Initialize("timer1",1000) 2. click the start button, timer1 is enabled Code: Copy Sub Button1_Click Timer1.Enabled=True End Sub The code goes let´s say: Code: Copy Sub Timer1_tick Label1.text=Label1.text+1 Dim n As Notification n.Initialize n.Vibrate=False n.Sound=False n.Icon = "icon" n.SetInfo("CountDown", Label1.text, "") n.Notify(1) End Sub Now when the counter counts up to 10,20, 60 or anything I set up I would like to play a sound, beep or anything, which it also does - IF the app is in foreground and IF the screen is ON(Sure I can set the screen to be awake inapp), the thing is as soon as I open a new app(messaging etc) the counter app doesn´t play sound or beep as soon it reaches 10,20,60. I´ve tried to solve it with service but the best I achieved is to put app in foreground as soon I open any other app. Thank you very much
DonManfred Expert Licensed User Longtime User Feb 13, 2017 #2 Move the code to the starter service. If the desired result is reached in the timer tick event then you can call a sub in a activity to show the notification. CallSubdelayed (which in fact will start an activity). You can for example use a blank activity which you´ll start (Callsubdelayed("MySub",mynotificationactivity). On start the mynotificationactivity activity will show the notification and then finish itself (Activity.finish). Upvote 0
Move the code to the starter service. If the desired result is reached in the timer tick event then you can call a sub in a activity to show the notification. CallSubdelayed (which in fact will start an activity). You can for example use a blank activity which you´ll start (Callsubdelayed("MySub",mynotificationactivity). On start the mynotificationactivity activity will show the notification and then finish itself (Activity.finish).
ebasic Member Licensed User Longtime User Feb 13, 2017 #3 Hello DonManfred, thanks for responding. I´ve tried the callsubdelayed and it stops working after 20-21 seconds (I´ve read on forum about the same issue) -basically I need the counter to count also in background (when screen off and when the app is not in foreground), but that doesn´t happen. I´ve seen ServiceExample where it works but can´t happen to issue any beep or sound while it´s not in foreground. Regards Upvote 0
Hello DonManfred, thanks for responding. I´ve tried the callsubdelayed and it stops working after 20-21 seconds (I´ve read on forum about the same issue) -basically I need the counter to count also in background (when screen off and when the app is not in foreground), but that doesn´t happen. I´ve seen ServiceExample where it works but can´t happen to issue any beep or sound while it´s not in foreground. Regards
DonManfred Expert Licensed User Longtime User Feb 13, 2017 #4 ebasic said: when screen off and when the app is not in foreground Click to expand... Use a service like i already told. ebasic said: beep or sound while it´s not in foreground. Click to expand... You need to start a activity for this (i already told this too). A Service cannot play sound or beep. Last edited: Feb 15, 2017 Upvote 0
ebasic said: when screen off and when the app is not in foreground Click to expand... Use a service like i already told. ebasic said: beep or sound while it´s not in foreground. Click to expand... You need to start a activity for this (i already told this too). A Service cannot play sound or beep.
ebasic Member Licensed User Longtime User Feb 13, 2017 #5 Thanks, I will try to do so (need to read more about services first) and update the thread according to results Regards Upvote 0
Thanks, I will try to do so (need to read more about services first) and update the thread according to results Regards
Erel B4X founder Staff member Licensed User Longtime User Feb 13, 2017 #6 Note that you can play audio from a service. Upvote 0
ebasic Member Licensed User Longtime User Feb 14, 2017 #7 Oh, with audio it works perfect now , thanks for help guys Upvote 0