Make a startup receiver. This gets fired when your device boots up.
Add the following to your manifest file (note the name StartupReceiver must match your receiver name in your code)
AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddReceiverText(StartupReceiver, <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>)
Next create a receiver called StartupReceiver in your code.
Sub Process_Globals
End Sub
'Called when an intent is received.
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
'This receiver is called when the device has successfully rebooted.
'All we're going to do here is start the NotifyReceiver
'which will set itself to run every ten minutes
StartReceiverAt(NotifyReceiver, DateTime.Now + 10 * DateTime.TicksPerMinute, True)
End Sub
Then we create another receiver - NotifyReceiver in my case -
Sub Process_Globals
End Sub
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
'Use a keyvalue store to pass info
Log ("NotifyReceiver Fired!")
'Do whatever you neeed here - Start an activity, fire off a reminder, whatever.
StartReceiverAt (Me, DateTime.Now + 10 * DateTime.TicksPerMinute , True) 'Set a new receiver to fire in 10 minutes time
End Sub
Remember - Receivers get killed off quite quickly so if you need to do a lot of processing then you need to start an activity. Also don't expect your receiver to fire exactly ten minutes after it's been set. I've found it's rarely on time.