0

I'm implementing Parse push notification. I have 2 receivers. First one will always show notification and second one will take over notification if one particular activity is running. One registered in manifest (priority 1) and the other is registered/unregistered dynamically (priority 2). My problem is that I cant cancel the broadcast from my dynamic receiver by calling

abortBroadcast()

it throws an exception

BroadcastReceiver trying to return result during a non-ordered broadcast

So, is there a way to make the broadcast ordered or something like that? I really want to handle the data in my activity when it is active.

2
  • 1
    are you sure you are using sendOrderedBroadcast instead of sendBroadcast when sending the Intent? Commented Jan 27, 2015 at 17:45
  • i'm not using anything. i think the broadcast is send by Parse's own service PushService (registered in manifest). I think its not an ordered broadcast. Is there any way to override it? I want my activity to get the data if it is active. Commented Jan 27, 2015 at 17:54

1 Answer 1

1

Ok, after 2 hrs of searching, finally solved it. This is what I did,

First I created a base BroadcastReceiver which receives the push notification from Parse. It then removes all actions from received intent and adds a custom action eg, com.myclass.PUSH Then I used

context.sendOrderedBroadcast(intent, null);

to send a new ordered broadcast using my custom action.

Now I set other two receiver's (the one defined in manifest and my dynamic receiver defined in activity) action to com.myclass.PUSH

Now the broadcast is ordered and i can cancel it using abortBroadcast()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.