4
In my application I have a BroadCast
who receives push notifications
in background
, that push
currently opens an Activity with the information of a request to be accepted, what happens is that if at the same time you are reading a request receive another the app opens on top of a new Intent.
public class BroadcastReceiverOneSignal extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getBundleExtra("data");
try {
JSONObject customJSON = new JSONObject(extras.getString("custom"));
if(customJSON.has("a")){
String id = customJSON.getJSONObject("a").getString(Constants.ID_CORRIDA);
Intent i = new Intent(context, Activty.class);
i.putExtra(Constants.ID, id);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}catch (Exception e){
e.printStackTrace();
}
}
}
I can keep all data from other orders if I receive a new one?
– Mateus Carvalho
Yes, the new will be received in the method
onNewIntent()
– ramaral