List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION
int TYPE_NOTIFICATION
To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.
Click Source Link
From source file:com.kasoft.pushnot.GcmIntentService.java
private void sendNotification(String msg, String title, String form) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent appMainIntent = new Intent(getApplicationContext(), MainActivity.class); appMainIntent.putExtra("title", title); appMainIntent.putExtra("form", form); //appMainIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); appMainIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, appMainIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(form)).setContentText(form); mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:br.ufc.quixada.dsdm.myapplicationtestemulttabs.googleGCM.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w w w. jav a2 s .c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivityTabMensagens.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.mensageiro_icon).setContentTitle("MENSSAGEIRO").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.company.millenium.iwannask.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param data GCM message received.//from w w w . j a v a 2 s.com */ private void sendNotification(Bundle data) { String question_body = data.getString("question_body"); String answer_body = data.getString("answer_body"); String question_id = data.getString("question_id"); //String answer_id = data.getString("answer_id"); String user_name = data.getString("user_name"); if (user_name != null && user_name.contains(" ")) { user_name = user_name.split(" ")[0]; } String type = data.getString("type"); Intent intent = new Intent(this, MainActivity.class); intent.putExtra("url", "/questions/" + question_id); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_CANCEL_CURRENT); String info = " answered:"; if (type != null && type.contentEquals("answer_feedback")) { String isLiked = data.getString("feedback_value"); info = " disliked your answer"; if (isLiked != null && isLiked.equals("true")) { info = " liked your answer"; } } else if (type != null && type.contentEquals("question_answer_op")) { info = " commented on"; } Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_comment_question_outline_grey600_36dp).setContentTitle(user_name + info) .setContentText(question_body) .setStyle(new NotificationCompat.BigTextStyle().bigText(question_body + "\n" + answer_body)) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(id, notificationBuilder.build()); id = id + 1; }
From source file:com.hugosama.samalinne.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from w w w . ja v a 2 s . com*/ private void sendNotification(String messageBody) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Bitmap image = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Samalinne").setContentText(messageBody) .setAutoCancel(true).setLargeIcon(image).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.donteatalone.asheeshsharma.capstone_porject2.fcm.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from ww w. j a v a 2s. co m private void sendNotification(String messageBody) { Intent intent = new Intent(this, LoginChatActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.sample_img2).setContentTitle("SendBird").setContentText(messageBody) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:asia.covisoft.goom.gcm.GoOmUserGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w w w .jav a 2s . com*/ */ private void sendNotification(String message, Driverconfirm response) { Intent intent = new Intent(this, HistoryDetailsActivity.class); trandingId = response.getTradingid(); intent.putExtra(Extras.TRADING_ID, trandingId); intent.putExtra(Extras.HISTORY_STATE, false); if (response.getValue().equals("tip")) { intent.putExtra(Extras.REQUEST_TIP, true); intent.putExtra(Extras.MAX_TIP, response.getMaxsuggest()); intent.putExtra(Extras.MIN_TIP, response.getMinsuggest()); cancelTip(); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle(getString(R.string.app_name_full)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.androdevlinux.percy.bitfly.Core.Services.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from w w w . j a v a 2 s . c o m*/ private void sendNotification(String messageBody) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_menu_camera).setContentTitle("FCM Message").setContentText(messageBody) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:fr.bmartel.android.tictactoe.gcm.MyGcmListenerService.java
/** * Called when message is received.// w w w.ja v a2s .c o m * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); if (from.startsWith("/topics/" + GameSingleton.DEVICE_ID)) { Log.d(TAG, "Message: " + message); try { JSONObject object = new JSONObject(message); ArrayList<String> eventItem = new ArrayList<>(); eventItem.add(object.toString()); broadcastUpdateStringList(BroadcastFilters.EVENT_MESSAGE, eventItem); if (!GameSingleton.activityForeground) { if (object.has(RequestConstants.DEVICE_MESSAGE_TOPIC) && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID) && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) { GameMessageTopic topic = GameMessageTopic .getTopic(object.getInt(RequestConstants.DEVICE_MESSAGE_TOPIC)); ChallengeMessage challengeMessage = new ChallengeMessage(topic, object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID), object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)); Log.i(TAG, "challenged by " + challengeMessage.getChallengerName() + " : " + challengeMessage.getChallengerId()); Intent intent2 = new Intent(this, DeviceListActivity.class); intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Fight!") .setContentText("challenged by " + challengeMessage.getChallengerName()) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(new Random().nextInt(9999), notificationBuilder.build()); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); boolean isScreenOn = pm.isScreenOn(); if (isScreenOn == false) { PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyLock"); wl.acquire(10000); PowerManager.WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyCpuLock"); wl_cpu.acquire(10000); } GameSingleton.pendingChallengeMessage = challengeMessage; GameSingleton.pendingChallenge = true; } } } catch (JSONException e) { e.printStackTrace(); } } }
From source file:com.dotcom.jamaat.fcm.GCMListenerService.java
/** * Create and show a simple notification containing the received GCM * message./*from w w w . j a v a 2 s. c o m*/ * <p/> * <p/> * GCM message received. */ public void displayNotificationInNotificationBar(Map data) { try { String messageData = data.get("message").toString(); int notifyID = Constants.NOTIFICATION_ID; //String eData = data.getString("extra_data"); String message = ""; if (!TextUtils.isEmpty(messageData)) { JSONObject extra_data = new JSONObject(messageData); message = extra_data.optString("message"); } // This intent is fired when notification is clicked NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Intent intent; String messages = SharedPreferencesManager.getStringPreference("notificationMessage", null); if (messages != null && !messages.isEmpty()) { messages = message + ";" + messages; SharedPreferencesManager.setPreference("notificationMessage", messages); intent = new Intent(this, NotificationActivity.class); } else { SharedPreferencesManager.setPreference("notificationMessage", message); intent = new Intent(this, NotificationActivity.class); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); String currentMessages = SharedPreferencesManager.getStringPreference("notificationMessage", null); String[] messagesArray = currentMessages.split(";"); int count = messagesArray.length; if (messagesArray.length == 0) { notificationManager.cancel(notifyID); return; } final String GROUP_KEY_MESSAGES = "group_key_messages"; // Group notification that will be visible on the phone NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); mBuilder.setTicker(getString(R.string.app_name)).setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.app_name)).setSound(defaultSoundUri).setAutoCancel(true) .setOnlyAlertOnce(false).setPriority(Notification.PRIORITY_MAX) // .setOngoing(true) // .setWhen( System.currentTimeMillis() ) .setContentIntent(pendingIntent).setSmallIcon(R.mipmap.ic_launcher).setGroup(GROUP_KEY_MESSAGES) .setGroupSummary(true).build(); NotificationCompat.Style style; if (count > 1) { NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); style = inboxStyle; mBuilder.setContentTitle(getString(R.string.app_name)); for (String r : messagesArray) { inboxStyle.addLine(r); } mBuilder.setContentText(count + " new messages"); inboxStyle.setBigContentTitle(getString(R.string.app_name)); inboxStyle.setSummaryText(count + " new messages"); } else { NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); style = bigTextStyle; // bigTextStyle.setBigContentTitle(messagesArray[0].substring(0, 10).concat(" ...")); bigTextStyle.setBigContentTitle(getString(R.string.app_name)); mBuilder.setContentText(message); bigTextStyle.bigText(message); // bigTextStyle.setSummaryText(count + " new event"); } mBuilder.setStyle(style); NotificationManagerCompat notificationManager1 = NotificationManagerCompat.from(this); notificationManager1.notify(notifyID, mBuilder.build()); } catch (Exception ex) { } }
From source file:com.bosco.noticeboard.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param note Notice received from server. *//* ww w. j ava 2 s. c om*/ private void sendNotification(Notice note) { Intent intent = new Intent(this, NoticeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("Notice", note); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setContentTitle(note.subject).setSmallIcon(R.drawable.normal_bell).setContentText(note.content) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); if (note.priority == 1) { notificationBuilder.setColor(getResources().getColor(R.color.icon_normal)); } else if (note.priority == 2) { notificationBuilder.setColor(getResources().getColor(R.color.icon_important)); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }