Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JSONObject request=messageContent.getJSONObject("request");
- intent = new Intent(getApplicationContext(), NewRequest.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
- intent.putExtra(NewRequest.REQUEST, String.valueOf(request));
- Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, id, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
- .setSmallIcon(R.mipmap.ic_launcher)
- .setContentText(body)
- .setContentTitle(title)
- .setAutoCancel(true)
- .setColor(ContextCompat.getColor(this, R.color.colorPrimary))
- .setVibrate(new long[] { 1000, 1000 })
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
- .setSound(defaultSoundUri)
- .setContentIntent(pendingIntent);
- Notification notification = notificationBuilder.build();
- notification.defaults |= Notification.DEFAULT_VIBRATE;
- notification.defaults |= Notification.DEFAULT_SOUND;
- NotificationManager notificationManager =
- (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- PowerManager.WakeLock wl = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "My Tag");
- wl.acquire(10000);
- notificationManager.notify(id, notification);
- TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
- stackBuilder.addParentStack(NewRequest.class);
- stackBuilder.addNextIntent(intent);
- PendingIntent pendingIntent =
- stackBuilder.getPendingIntent(id, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement