I am trying to communicate/update UI from Service to activity. The broadcast I receive is not what I had sent. Any ideas why?
Service code:
@Override
//binder returns NULL
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Intent i = new Intent();
i.putExtra("lol", "haha");
i.setAction(MYACTION);
sendBroadcast(i);
Activity code:
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
IntentFilter intentFilter = new IntentFilter(MYACTION);
registerReceiver(recv, intentFilter);
}
BroadcastReceiver recv = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Intent getintent = getIntent();
String action = getintent.getAction();
//ACTION RECEIVED IS DIFFERENT FROM MYACTION. IT IS ACTION.MAIN
// VALUE RECEIVED IS NULL
String val = getintent.getStringExtra("lol");
}
I have not registered the receiver in manifest. Is it necessary?
As mentioned in comments: I do not receive the same action in broadcast receiver and the value from intent is NULL.
What am I doing wrong?
Thanks for your help.