Android Question service module

Isac

Active Member
Licensed User
Longtime User
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:

Isac

Active Member
Licensed User
Longtime User
This is the log of the service module boot


** Service (boot) Start **

An error occurred:
(Line: 20) StartServiceAt(starts,"date",False)
java.lang.NumberFormatException: For input string: "date"


Error occurred on line: 0 (Keyvaluestore)
java.lang.NumberFormatException: Invalid double: "date"
 
Last edited:
Upvote 0

Isac

Active Member
Licensed User
Longtime User
how to convert from string to long?

B4X:
 #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 memoria As Keyvaluestore
   
 
End Sub
Sub Service_Create
memoria.Initialize(File.DirDefaultExternal,"datastore") 
End Sub

Sub Service_Start (StartingIntent As Intent)
DateTime.Time(memoria.GetSimple("date"))
StartServiceAt(starts,conv,False)
StopService("")


End Sub

Sub Service_Destroy

End Sub
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
You should check the dictionnary for this :
DateTime.Time(memoria.GetSimple("date"))
It seems not to be the correct use.

Please what is the purpose of this value (I mean where after that do you use it) ? Is this for the conv variable ?
 
Last edited:
Upvote 0

Isac

Active Member
Licensed User
Longtime User
Sorry I tried:

Dim conv as long

conv = "date"

but rightly does not work

Currently it is so:


B4X:
 #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 memoria As Keyvaluestore

   
End Sub
Sub Service_Create
memoria.Initialize(File.DirDefaultExternal,"datastore")   
End Sub

Sub Service_Start (StartingIntent As Intent)
DateTime.Time(memoria.GetSimple("date"))

StartServiceAt(starts,"date",False)
StopService("")


End Sub

Sub Service_Destroy

End Sub
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Thanks, so, if the desired date was stored correctly, I mean in a correct format, you could perhaps try :

B4X:
Sub Service_Start (StartingIntent AsIntent)

'Here we recover the stored date in a String format from the file
Dim dTemp as String =memoria.GetSimple("date")

'This is a stupid sample for forcing type casting (we get a string and force transform to a Long)
Dim dLong as Long =dTemp

StartServiceAt(starts,dLong,False)
StopService("")
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…