Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onPushOpen(Context context, Intent intent) {
- String uriString = null;
- try {
- JSONObject pushData = new JSONObject(intent.getStringExtra("com.parse.Data"));
- uriString = pushData.optString("uri");
- } catch (JSONException e) {
- Log.v("com.parse.ParsePushReceiver", "Unexpected JSONException when receiving push data: ", e);
- }
- Class<? extends Activity> cls = getActivity(context, intent);
- Intent activityIntent;
- if (uriString != null && !uriString.isEmpty()) {
- activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString));
- } else {
- activityIntent = new Intent(context, NewsActivity.class);
- }
- activityIntent.putExtras(intent.getExtras());
- if (Build.VERSION.SDK_INT >= 16) {
- TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
- stackBuilder.addParentStack(cls);
- stackBuilder.addNextIntent(activityIntent);
- stackBuilder.startActivities();
- } else {
- activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- context.startActivity(activityIntent);
- }
- NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.cancelAll();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement