private void sendNotification(String text) { NotificationManager mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notification = new NotificationCompat.Builder(ctx); notification.setContentTitle(ctx.getString(R.string.app_name)); notification.setContentText(text); notification.setAutoCancel(true); if (Common.isVibrate()) { notification.setDefaults(Notification.DEFAULT_VIBRATE); } notification.setSmallIcon(R.drawable.ic_launcher); if (!TextUtils.isEmpty(Common.getRingtone())) { notification.setSound(Uri.parse(Common.getRingtone())); } mNotificationManager.notify(0, notification.build()); }
private void newMessageNotification(String text, String senderEmail) { NotificationManager mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notification = new NotificationCompat.Builder(ctx); notification.setContentTitle(ctx.getString(R.string.app_name) + "-" + text); notification.setContentText(senderEmail); notification.setAutoCancel(true); if (Common.isVibrate()) { notification.setDefaults(Notification.DEFAULT_VIBRATE); } notification.setSmallIcon(R.drawable.ic_launcher); if (!TextUtils.isEmpty(Common.getRingtone())) { notification.setSound(Uri.parse(Common.getRingtone())); } Intent intent = new Intent(ctx, ChatActivity.class); intent.putExtra(Common.IS_NOTIF, true); intent.putExtra(Common.PROFILE_NAME, senderEmail); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(ctx, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK); notification.setContentIntent(pi); mNotificationManager.notify(1, notification.build()); }