handling broadcast reciver
- by rayman
Hi,
I have an app which has MainActivity(without gui.. please just flow with it:) )
now this MainActivity running a service, this service using sendBroadcast() in order to comunnicate with the MainActivity..
now ofcourse i need to registerReceiver in the onResume() of the MainActivity.
but i also need to add unregisterReceiver(receiver) in the onDestroy() of the MainActivity.
problem is: when i first start that app i need it to up the service, and i dont want the user to lose focus, so i press finish() after i`am starting the service.. but then auto invoked also
unregisterReceiver(receiver).. and this is not good for me.. i get error it's said it couldnt find any registerd reciver.
so i fixed it by delete this line.. but i am sure its going to 'revenege' me in the future, when/where could i have problem if i wont use unregisterReceiver(receiver).. at the onDestroy()
thanks,
ray.