I am creating a service using the 'shake' procedures from Erel, but when I try to display it int he Android message bar, I use SetInfo for a Notification. But for my notification, the info I have in SetInfo is not used and it does not launch my Main routine, instead it opens the Android service window to manage apps???
Why??
Here's my service:
Why??
Here's my service:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim INIisloaded As Boolean = False
Dim sensor As PhoneSensors
Dim ShakeWasActivated As Boolean = False
Type Element (NextElement As Element, Val As String)
Dim Map1 As Map
'Dim Notification As Notification
Dim EventNotif As Notification
'ini settings here........................................
Dim ServicesvrIP As String = ""
Dim ServicesvrPORT As Int = 7234
Dim ServiceAPPid As String = "EZshake" 'ID of this app
Dim ModePullpin As String = "No"
End Sub
Sub Service_Create
'load the EZshake settings..
Map1.Initialize 'init the ini file map
LoadIni (File.DirDefaultExternal,"EZshake.ini")
EventNotif.Initialize
EventNotif.Icon = "TelShake" 'icon or eiconalarm etc.. case sensitive save icons to source folder\Objects\res\drawable
EventNotif.Light = False
EventNotif.Sound = False
EventNotif.Vibrate = False
EventNotif.Insistent = True
EventNotif.AutoCancel = False
EventNotif.SetInfo("EZlinc Shake Alarm", "Shake this device to trigger an alarm..", Main)
Service.StartForeground(1, EventNotif)
sensor.Initialize(sensor.TYPE_ACCELEROMETER)
Shake.CallBackActivity = "ShakeService" 'Set the activity that handles the Shake event
End Sub
Sub Service_Start (StartingIntent As Intent)
sensor.StartListening("sensor")
ToastMessageShow("listening to sensors",True)
End Sub
Sub Service_Destroy
sensor.StopListening
Service.StopForeground(1)
SaveIni (File.DirDefaultExternal,"EZshake.ini")
EventNotif.Cancel(1) 'remove the taskbar icon..
End Sub
Sub sensor_SensorChanged (Values() As Float)
Shake.HandleSensorEvent(Values)
End Sub
'This event is raised when a shake is detected
Sub ShakeEvent
ShakeWasActivated = True
StartActivity(Main)
End Sub