Use the Notifier.LogInfo method as debug statements and use logcat to debug
You do not need the inner if statement it is wrong anyway (should be if not connected)
Write your MessageReceived event handler
EDIT: first prepare a simple example which is working in the foreground and show your working blocks so we can compare with your blocks from the background processing