Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. @Override
  2.     protected void onPushOpen(Context context, Intent intent) {
  3.  
  4.         String uriString = null;
  5.         try {
  6.             JSONObject pushData = new JSONObject(intent.getStringExtra("com.parse.Data"));
  7.             uriString = pushData.optString("uri");
  8.         } catch (JSONException e) {
  9.             Log.v("com.parse.ParsePushReceiver", "Unexpected JSONException when receiving push data: ", e);
  10.         }
  11.         Class<? extends Activity> cls = getActivity(context, intent);
  12.         Intent activityIntent;
  13.         if (uriString != null && !uriString.isEmpty()) {
  14.             activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString));
  15.         } else {
  16.             activityIntent = new Intent(context, NewsActivity.class);
  17.         }
  18.         activityIntent.putExtras(intent.getExtras());
  19.         if (Build.VERSION.SDK_INT >= 16) {
  20.             TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
  21.             stackBuilder.addParentStack(cls);
  22.             stackBuilder.addNextIntent(activityIntent);
  23.             stackBuilder.startActivities();
  24.         } else {
  25.             activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  26.             activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  27.             context.startActivity(activityIntent);
  28.         }
  29.         NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  30.         notificationManager.cancelAll();
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement