Android Question Modul Activity - Service

MarcoRome

Expert
Licensed User
Longtime User
Hi all, this code working if i have Activity module in background. If Activity i have in foreground ( Press Home Keyboard ) the Service ( AlarmService ) lost value in Main.mp3.

Activity-Modul:
B4X:
Sub Process_Globals
 
'These variables can be accessed from all modules.
 
Dim mp3 as string
 
Dimp mp as MediaPlayer
 
Dim noti As Notification
 
...
 
Sub Test
 
......
 
StartServiceAt(AlarmService, (DateTime.Now+((h*60*60*1000)+(m*60*1000))), True)
 
End Sub

Service:

B4X:
.....
Sub Service_Start
Main.mp.Initialize()  'Initialize Mediaplayer
PlayAlarm
ToastMessageShow("Run....", True)
End Sub
 
Sub Service_Destroy
    StopService("")    'Stop this service
    CancelScheduledService("")  'Cancel this service
End Sub
 
 Sub PlayAlarm
Main.mp.Load(File.DirAssets, Main.mp3)
Main.mp.Play
End Sub

Why ??
Thank you all
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…