So I want when my push notifications was received and user clicked it, I want to send some data to activity, so that it won't be reopened again, I've tried to send broadcast, but broadcast is not receiving data for some reason.
if(!MainActivity.mStarted) {
contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class).putExtra("push", "true"), PendingIntent.FLAG_UPDATE_CURRENT);
} else {
contentIntent = PendingIntent.getBroadcast(this, 0,
new Intent(this, MainActivity.class).putExtra("push", "true")
.setAction(ACTION_RECEIVED),PendingIntent.FLAG_NO_CREATE);
}
And in activity:
@Override
protected void onResume() {
super.onResume();
myBroadcastReceiver = new MyBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(
GcmIntentService.ACTION_RECEIVED);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
registerReceiver(myBroadcastReceiver, intentFilter);
final OrdersFragment fragment = (OrdersFragment) getFragmentManager().findFragmentByTag(ORDERS_TAG);
}
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("GOT", "SOMETHING");
}
}
Maybe I'm doing something wrong, then how can I perform my activity to update, and not reopen itself?
P.S. could you please instead of placing a minus for question make a normal reply of how can I improve my code or improve my question?