Isac Active Member Licensed User Longtime User Apr 5, 2014 #1 Hello, I have a problem with the service module: If I turn off and then I turn on the phone the alarm does not work. I tried to use: # StartAtBoot: True But as soon as I turn on the phone immediately starts the service module, but this is not good. thanks Last edited: Apr 5, 2014
Hello, I have a problem with the service module: If I turn off and then I turn on the phone the alarm does not work. I tried to use: # StartAtBoot: True But as soon as I turn on the phone immediately starts the service module, but this is not good. thanks
DonManfred Expert Licensed User Longtime User Apr 5, 2014 #2 You run into the same problem like the one in this thread. See the comments there and you´ll have a solution for your problem Upvote 0
You run into the same problem like the one in this thread. See the comments there and you´ll have a solution for your problem
Isac Active Member Licensed User Longtime User Apr 7, 2014 #3 Thanks DonManfred, Do you have any example to show me. Hello Upvote 0
DonManfred Expert Licensed User Longtime User Apr 7, 2014 #4 No, i just thinked over what the sulution can be. Erel stated that my thoughts were right. But i dont have an example, sorry. Upvote 0
No, i just thinked over what the sulution can be. Erel stated that my thoughts were right. But i dont have an example, sorry.
Erel B4X founder Staff member Licensed User Longtime User Apr 7, 2014 #5 But as soon as I turn on the phone immediately starts the service module, but this is not good. Click to expand... There are several ways to solve it. The simplest is to use a different service to handle the boot intent. Upvote 0
But as soon as I turn on the phone immediately starts the service module, but this is not good. Click to expand... There are several ways to solve it. The simplest is to use a different service to handle the boot intent.
Isac Active Member Licensed User Longtime User Apr 11, 2014 #6 Erel how can I change the service module? I have no idea, now when I turn on the phone sevice module starts by itself. thanks Code: Copy #Region Service Attributes #StartAtBoot: True #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim n As Notification End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) n.Initialize n.Icon = "icon" n.SetInfo("warning ", "You have reached the date","") n.Notify(1) End If End Sub Sub Service_Destroy StopService("") 'Stop this service CancelScheduledService("") 'Cancel this service End Sub Upvote 0
Erel how can I change the service module? I have no idea, now when I turn on the phone sevice module starts by itself. thanks Code: Copy #Region Service Attributes #StartAtBoot: True #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim n As Notification End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) n.Initialize n.Icon = "icon" n.SetInfo("warning ", "You have reached the date","") n.Notify(1) End If End Sub Sub Service_Destroy StopService("") 'Stop this service CancelScheduledService("") 'Cancel this service End Sub
Erel B4X founder Staff member Licensed User Longtime User Apr 13, 2014 #7 Create another service and set the second service to start at boot. You can then call StartServiceAt from the second service to schedule the first one. Upvote 0
Create another service and set the second service to start at boot. You can then call StartServiceAt from the second service to schedule the first one.
Isac Active Member Licensed User Longtime User Apr 15, 2014 #8 Erel I created the new service module, now how do I share the given variable of the module Main? Code: Copy #Region Service Attributes #StartAtBoot: true #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) StartServiceAt(start,date,False) End Sub Sub Service_Destroy Upvote 0
Erel I created the new service module, now how do I share the given variable of the module Main? Code: Copy #Region Service Attributes #StartAtBoot: true #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) StartServiceAt(start,date,False) End Sub Sub Service_Destroy
lemonisdead Well-Known Member Licensed User Longtime User Apr 15, 2014 #9 Hi, To retrieve Process_Globals you have to reference it by the module's name and the variable name. For example : Main.Variable_Name Of course, Variable_Name should not be Private Tip: Sometimes it is easier to store the content of the variable in a file and retrieve it from the running service. Just an idea in case of. Upvote 0
Hi, To retrieve Process_Globals you have to reference it by the module's name and the variable name. For example : Main.Variable_Name Of course, Variable_Name should not be Private Tip: Sometimes it is easier to store the content of the variable in a file and retrieve it from the running service. Just an idea in case of.
Isac Active Member Licensed User Longtime User Apr 15, 2014 #10 thanks I tried to insert Main.date, but the variable does not see it. Parsing code. Error Error parsing program. Error description: Undeclared variable 'date' is used before it was assigned any value. Occurred on line: 19 StartServiceAt(start,date,False) Code: Copy #Region Service Attributes #StartAtBoot: true #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Main.date End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) StartServiceAt(start,date,False) End Sub Sub Service_Destroy End Sub Upvote 0
thanks I tried to insert Main.date, but the variable does not see it. Parsing code. Error Error parsing program. Error description: Undeclared variable 'date' is used before it was assigned any value. Occurred on line: 19 StartServiceAt(start,date,False) Code: Copy #Region Service Attributes #StartAtBoot: true #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Main.date End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) StartServiceAt(start,date,False) End Sub Sub Service_Destroy End Sub
lemonisdead Well-Known Member Licensed User Longtime User Apr 15, 2014 #11 Excuse, this is not the correct usage. In the Main activitiy Code: Copy Sub Process_Globals Dim Date1 as Long End Sub And in the Service module you make the reference to the Main.date1 Code: Copy #Region Service Attributes #StartAtBoot: true #End Region Sub Process_Globals 'These global variables will be declared once when the application starts.'These variables can be accessed from all modules. End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent AsIntent) StartServiceAt(start,Main.date1,False) StopService("") End Sub Sub Service_Destroy End Sub Upvote 0
Excuse, this is not the correct usage. In the Main activitiy Code: Copy Sub Process_Globals Dim Date1 as Long End Sub And in the Service module you make the reference to the Main.date1 Code: Copy #Region Service Attributes #StartAtBoot: true #End Region Sub Process_Globals 'These global variables will be declared once when the application starts.'These variables can be accessed from all modules. End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent AsIntent) StartServiceAt(start,Main.date1,False) StopService("") End Sub Sub Service_Destroy End Sub
Isac Active Member Licensed User Longtime User Apr 17, 2014 #12 Thanks lemonisdead, That's fine but when I restart the phone the service module will start automatically without waiting for launch date. this is the first service module called (boot) Code: Copy #Region Service Attributes #StartAtBoot: True #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) StartServiceAt(start,Main.date,False) StopService("") End Sub Sub Service_Destroy End Sub This is the second service module called (start) Code: Copy #Region Service Attributes #StartAtBoot: False #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim n As Notification End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) n.Initialize n.Icon = "icon" n.SetInfo("warning ", "You have reached the date","") n.Notify(1) End Sub Sub Service_Destroy StopService("") 'Stop this service CancelScheduledService("") 'Cancel this service End Sub this is a piece of code Main Code: Copy date=DateTime.Add(DATA,0,0,Giorni) StartServiceAt(boot,date,False) I do not understand why the service module boot starts without waiting for the date. Upvote 0
Thanks lemonisdead, That's fine but when I restart the phone the service module will start automatically without waiting for launch date. this is the first service module called (boot) Code: Copy #Region Service Attributes #StartAtBoot: True #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) StartServiceAt(start,Main.date,False) StopService("") End Sub Sub Service_Destroy End Sub This is the second service module called (start) Code: Copy #Region Service Attributes #StartAtBoot: False #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim n As Notification End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) n.Initialize n.Icon = "icon" n.SetInfo("warning ", "You have reached the date","") n.Notify(1) End Sub Sub Service_Destroy StopService("") 'Stop this service CancelScheduledService("") 'Cancel this service End Sub this is a piece of code Main Code: Copy date=DateTime.Add(DATA,0,0,Giorni) StartServiceAt(boot,date,False) I do not understand why the service module boot starts without waiting for the date.
DonManfred Expert Licensed User Longtime User Apr 17, 2014 #13 On device reboot the date you set is lost... Save the date when setting the servicestartat to somewhere... Key value store, db, statemanger, whatever.. On service start at boot you check whether the desired date is reached or not. If not then set the new startat and quit. If the date is reached or in ast then do the work. Search the forum. There was a few threads handling this issue... Upvote 0
On device reboot the date you set is lost... Save the date when setting the servicestartat to somewhere... Key value store, db, statemanger, whatever.. On service start at boot you check whether the desired date is reached or not. If not then set the new startat and quit. If the date is reached or in ast then do the work. Search the forum. There was a few threads handling this issue...
Isac Active Member Licensed User Longtime User Apr 18, 2014 #14 I have to be stored in an external file by following this link? http://www.b4x.com/android/forum/th...ple-and-efficient-key-value-data-store.26317/ Upvote 0
I have to be stored in an external file by following this link? http://www.b4x.com/android/forum/th...ple-and-efficient-key-value-data-store.26317/
lemonisdead Well-Known Member Licensed User Longtime User Apr 18, 2014 #15 Hi Isac, You can use several methods. You could take a look at the File keyword. For example, you can save a list or a map with the useful information. Upvote 0
Hi Isac, You can use several methods. You could take a look at the File keyword. For example, you can save a list or a map with the useful information.
Isac Active Member Licensed User Longtime User Apr 22, 2014 #16 Hi Lemonisdead, I could use the TextWriter to save the date of a txt file? and then recall it with TextReader? thanks Upvote 0
Hi Lemonisdead, I could use the TextWriter to save the date of a txt file? and then recall it with TextReader? thanks
Isac Active Member Licensed User Longtime User Apr 24, 2014 #17 I am using the class Keyvaluestore: But I need your help because it does not work. This main module Code: Copy dim memoria as Keyvaluestore date=DateTime.Add(DATA,0,0,Giorni) memoria.Initialize(File.DirDefaultExternal,"datastore") memoria.PutSimple("date",date) StartServiceAt(boot,date,False) This module boot Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. dim memoria as Keyvaluestore End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) memoria.Initialize(File.DirDefaultExternal,"datastore") DateTime.date(memoria.GetSimple("date")) StartServiceAt(starts,"date",False) StopService("") Starsts module is OK Last edited: Apr 24, 2014 Upvote 0
I am using the class Keyvaluestore: But I need your help because it does not work. This main module Code: Copy dim memoria as Keyvaluestore date=DateTime.Add(DATA,0,0,Giorni) memoria.Initialize(File.DirDefaultExternal,"datastore") memoria.PutSimple("date",date) StartServiceAt(boot,date,False) This module boot Code: Copy Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. dim memoria as Keyvaluestore End Sub Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) memoria.Initialize(File.DirDefaultExternal,"datastore") DateTime.date(memoria.GetSimple("date")) StartServiceAt(starts,"date",False) StopService("") Starsts module is OK
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2014 #18 Do you get any error message? Upvote 0
Isac Active Member Licensed User Longtime User Apr 24, 2014 #19 In compiling no errors but when I turn off and turn on the phone comes out a message saying that the application will be blocked. Upvote 0
In compiling no errors but when I turn off and turn on the phone comes out a message saying that the application will be blocked.
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2014 #20 Not sure what you mean with application will be blocked. If the process crashes then there should be an error message in the logs. Upvote 0
Not sure what you mean with application will be blocked. If the process crashes then there should be an error message in the logs.