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.sopinet.trazeo.app.chat.GcmIntentService.java
public void launchNotification(Message message, Group group, String type, boolean showMessage) { Intent chatIntent = new Intent("com.sopinet.trazeo.app.chatmessage"); chatIntent.putExtra("groupId", group.id); chatIntent.putExtra("username", message.username); chatIntent.putExtra("time", message.time); chatIntent.putExtra("longId", message.getId()); sendBroadcast(chatIntent);/*from w w w .ja v a 2 s.co m*/ // If chat is not on foreground (visible), launch notifications if (group.chat != null && group.chat.visibility == 0) { Intent i = new Intent(this, ChatActivity_.class); i.putExtra("groupId", group.id); i.putExtra("fromNotification", true); String msg; switch (message.type) { case Message.RECEIVED: msg = "Nuevo mensaje en: " + group.name; break; default: msg = message.text; break; } NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(type.equals(TEXT) ? R.drawable.mascota_arrow : R.drawable.mascota_arrow2) .setContentTitle(getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setLights(0xFF0000FF, 100, 3000) .setContentText(msg).setAutoCancel(true); SharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE); //String notifications = sharedPreferences.getString("status_notifications", "on"); String sounds = sharedPreferences.getString("sounds", "on"); if (sounds.equals("on")) { mBuilder.setSound(alarmSound); } mBuilder.setContentIntent(contentIntent); switch (type) { case TEXT: if (sharedPreferences.getBoolean("chatsNotification", true)) mNotificationManager.notify(notificationId, mBuilder.build()); break; case RIDE_STARTED: case RIDE_FINISHED: if (sharedPreferences.getBoolean("RaidInOutNotification", true) && showMessage) mNotificationManager.notify(notificationId, mBuilder.build()); break; case CHILD_IN: case CHILD_OUT: if (sharedPreferences.getBoolean("childInOutNotification", true)) mNotificationManager.notify(notificationId, mBuilder.build()); break; } } }
From source file:com.mattprecious.notisync.profile.SecondaryCustomProfileActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile_custom_secondary); getSupportActionBar().setDisplayHomeAsUpEnabled(true); dbAdapter = new DbAdapter(this); if (getIntent().hasExtra("profile")) { profile = getIntent().getParcelableExtra("profile"); } else {// ww w . jav a 2 s .c om profile = new SecondaryProfile(); profile.setEnabled(true); profile.setVibrate(true); profile.setLed(true); } nameField = (EditText) findViewById(R.id.nameField); nameField.setText(profile.getName()); nameField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { validateName(); if (tagField.getText().length() == 0) { tagField.setText(nameField.getText().toString().toLowerCase(Locale.getDefault()) .replaceAll("\\s", "")); validateTag(); } } } }); tagField = (EditText) findViewById(R.id.tagField); tagField.setText(profile.getTag()); tagField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { validateTag(); } } }); tagRequestButton = (ImageButton) findViewById(R.id.tagRequestButton); tagRequestButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SherlockDialogFragment newFragment = new RequestTagsDialogFragment(); newFragment.show(getSupportFragmentManager(), null); } }); unconnectedOnlyCheckBox = (CheckBox) findViewById(R.id.unconnectedOnlyCheckBox); unconnectedOnlyCheckBox.setChecked(profile.isUnconnectedOnly()); ringtoneSelector = (Button) findViewById(R.id.ringtoneSelector); ringtoneSelector.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, getRingtoneUri(profile.getRingtone())); startActivityForResult(intent, REQUEST_CODE_RINGTONE_PICKER); } }); vibrateCheckBox = (CheckBox) findViewById(R.id.vibrateCheckBox); vibrateCheckBox.setChecked(profile.isVibrate()); checkForVibrator(); lightsCheckBox = (CheckBox) findViewById(R.id.lightsCheckBox); lightsCheckBox.setChecked(profile.isLed()); updateRingtoneSelector(); }
From source file:com.handshake.notifications.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. */// www.j av a 2 s. c o m private void sendNotification(final Bundle data, long userId, boolean isContact) { Intent intent; if (userId == 0) { intent = new Intent(this, MainActivity.class); } else if (isContact) { intent = new Intent(this, ContactUserProfileActivity.class); } else { intent = new Intent(this, GenericUserProfileActivity.class); } intent.putExtra("userId", userId); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 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("Handshake") .setContentText(data.getString("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:cs460.grouple.grouple.GcmIntentService.java
private void sendNotification(String msg) { updateMyActivity(this);// crash seems RECEIVER be here Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); if (TYPE.equals(CONTENT_TYPE.GROUP_MESSAGE.toString()) || TYPE.equals(CONTENT_TYPE.EVENT_MESSAGE.toString())) { Intent notificationIntent = new Intent(this, EntityMessagesActivity.class); if (TYPE.equals(CONTENT_TYPE.GROUP_MESSAGE.toString())) { notificationIntent.putExtra("CONTENT_TYPE", "GROUP"); notificationIntent.putExtra("GID", RECEIVER); Group g = new Group(Integer.parseInt(RECEIVER)); g.fetchGroupInfo();/*w ww .ja va 2s . co m*/ GLOBAL.setGroupBuffer(g); } else { notificationIntent.putExtra("CONTENT_TYPE", "EVENT"); notificationIntent.putExtra("EID", RECEIVER); Event e = new Event(Integer.parseInt(RECEIVER)); e.fetchEventInfo(); GLOBAL.setEventBuffer(e); } notificationIntent.putExtra("email", SENDER); notificationIntent.putExtra("name", NAME); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setContentTitle(NAME) .setStyle(new NotificationCompat.BigTextStyle() // .bigText(msg)) .bigText(SENDER_FIRST + " " + SENDER_LAST + ": " + msg)) .setSmallIcon(R.drawable.icon_grouple).setSound(soundUri).setContentText(msg); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setAutoCancel(true); // null check mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } else if (TYPE.equals(CONTENT_TYPE.USER_MESSAGE.toString())) { Intent notificationIntent = new Intent(getApplicationContext(), MessagesActivity.class); notificationIntent.putExtra("sender", SENDER); notificationIntent.putExtra("name", SENDER_FIRST + " " + SENDER_LAST); notificationIntent.putExtra("receiver", RECEIVER); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setContentTitle(SENDER_FIRST + " " + SENDER_LAST) .setStyle(new NotificationCompat.BigTextStyle() // .bigText(msg)) .bigText(msg)) .setSmallIcon(R.drawable.icon_grouple).setSound(soundUri).setContentText(msg); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setAutoCancel(true); // null check mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } else if (TYPE.equals(CONTENT_TYPE.FRIEND_REQUEST.toString())) { // Send friend request. Intent notificationIntent = new Intent(getApplicationContext(), ListActivity.class); notificationIntent.putExtra("email", GLOBAL.getCurrentUser().getEmail()); notificationIntent.putExtra("name", SENDER_FIRST + " " + SENDER_LAST); notificationIntent.putExtra("content", CONTENT_TYPE.FRIEND_REQUEST.toString()); GLOBAL.getCurrentUser().fetchFriendRequests(); GLOBAL.getCurrentUser().fetchUserInfo(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setContentTitle("New friend request from " + SENDER_FIRST + " " + SENDER_LAST + "!") .setStyle(new NotificationCompat.BigTextStyle().bigText(SENDER_FIRST + " " + SENDER_LAST)) .setSmallIcon(R.drawable.icon_grouple).setSound(soundUri).setContentText(msg); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setAutoCancel(true); // null check mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } else if (TYPE.equals(CONTENT_TYPE.GROUP_INVITE.toString())) { // Send friend request. Intent notificationIntent = new Intent(getApplicationContext(), ListActivity.class); notificationIntent.putExtra("email", GLOBAL.getCurrentUser().getEmail()); notificationIntent.putExtra("name", SENDER_FIRST + " " + SENDER_LAST); notificationIntent.putExtra("content", "GROUPS_INVITES"); GLOBAL.getCurrentUser().fetchFriendRequests(); GLOBAL.getCurrentUser().fetchUserInfo(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setContentTitle( "New group invite to " + NAME + " from " + SENDER_FIRST + " " + SENDER_LAST + "!") .setStyle(new NotificationCompat.BigTextStyle().bigText(SENDER_FIRST + " " + SENDER_LAST)) .setSmallIcon(R.drawable.icon_grouple).setSound(soundUri).setContentText(msg); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setAutoCancel(true); // null check mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
From source file:com.hmlee.chat.chatclient.fcm.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from w ww .jav a 2 s . c om*/ 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.mipmap.contact).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:com.example.dhaejong.acp2.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from ww w . j a va2 s .co m*/ */ private void sendNotification(String message, String title) { Intent intent = new Intent(this, Main2Activity.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_stat_ic_notification).setContentTitle(title).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.vis.GcmIntentService.java
private void sendNotification(String notificationMessage) { try {//from w w w . j a va 2 s . c o m mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Gson gson = new Gson(); NotificationMessage notification = gson.fromJson(notificationMessage, NotificationMessage.class); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Intent intent = new Intent(this, MainActivity.class); intent.putExtra("NOTIFICATION", notificationMessage); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Video in Short").setSound(alarmSound) .setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(notification.getMessage())) .setContentText(notification.getMessage()); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); Tracker t = ((Analytics) getApplication()).getDefaultTracker(); // Build and send an Event. t.send(new HitBuilders.EventBuilder().setCategory("GCM").setAction("Message") .setLabel("Message recieved").build()); } catch (JsonSyntaxException e) { e.printStackTrace(); } }
From source file:de.azapps.mirakel.reminders.ReminderAlarm.java
private static void createNotification(final Context context, final Task task) { Log.w(TAG, task.getName());/*from ww w . ja va 2s .com*/ final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final Optional<Class<?>> main = Helpers.getMainActivity(); if (!main.isPresent()) { return; } final Intent openIntent = new Intent(context, main.get()); final Bundle withTask = new Bundle(); withTask.putParcelable(DefinitionsHelper.EXTRA_TASK, task); openIntent.setAction(DefinitionsHelper.SHOW_TASK_REMINDER); openIntent.putExtra(DefinitionsHelper.EXTRA_TASK_REMINDER, task); openIntent.putExtra(String.valueOf(task.getId()), task.getId()); openIntent.setData(Uri.parse(openIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent pOpenIntent = PendingIntent.getActivity(context, 0, openIntent, 0); final Intent doneIntent = new Intent(context, TaskService.class); doneIntent.setAction(TaskService.TASK_DONE); doneIntent.putExtra(DefinitionsHelper.BUNDLE_WRAPPER, withTask); doneIntent.putExtra(String.valueOf(task.getId()), task.getId()); doneIntent.setData(Uri.parse(doneIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent pDoneIntent = PendingIntent.getService(context, 0, doneIntent, 0); final Intent laterIntent = new Intent(context, TaskService.class); laterIntent.setAction(TaskService.TASK_LATER); laterIntent.putExtra(DefinitionsHelper.BUNDLE_WRAPPER, withTask); laterIntent.putExtra(String.valueOf(task.getId()), task.getId()); laterIntent.setData(Uri.parse(laterIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent pLaterIntent = PendingIntent.getService(context, 0, laterIntent, 0); final boolean persistent = MirakelCommonPreferences.usePersistentReminders(); // Build Notification final NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setContentTitle(context.getString(R.string.reminder_notification_title, task.getName())) .setContentText(task.getContent()).setSmallIcon(R.drawable.ic_mirakel) .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, context)).setContentIntent(pOpenIntent) .setPriority(NotificationCompat.PRIORITY_HIGH).setLights(Color.BLUE, 1500, 300) .setOngoing(persistent).setDefaults(Notification.DEFAULT_VIBRATE) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .addAction(R.drawable.ic_checkmark_holo_light, context.getString(R.string.reminder_notification_done), pDoneIntent) .addAction(android.R.drawable.ic_menu_close_clear_cancel, context.getString(R.string.reminder_notification_later), pLaterIntent); final NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); final String priority = ((task.getPriority() > 0) ? ("+" + task.getPriority()) : String.valueOf(task.getPriority())); final CharSequence due; if (!task.getDue().isPresent()) { due = context.getString(R.string.no_date); } else { due = DateTimeHelper.formatDate(context, task.getDue()); } inboxStyle.addLine(context.getString(R.string.reminder_notification_list, task.getList().getName())); inboxStyle.addLine(context.getString(R.string.reminder_notification_priority, priority)); inboxStyle.addLine(context.getString(R.string.reminder_notification_due, due)); builder.setStyle(inboxStyle); // Build notification if (!allReminders.contains(task.getId())) { allReminders.add(task.getId()); nm.notify(DefinitionsHelper.NOTIF_REMINDER + (int) task.getId(), builder.build()); } }
From source file:com.smart.taxi.GcmIntentService.java
private void sendNotification(Object msg) { Intent intent;/* ww w .jav a 2 s .c o m*/ String message; int rid = r.nextInt(1800 - 650) + 650; try { Bundle extras = (Bundle) msg; String notifType = (Utils.isEmptyOrNull(extras.getString("type")) && extras.getString("status").equals("1")) ? "accept" : extras.getString("type"); String journeyId = extras.getString("journey_id"); message = extras.getString("message"); intent = new Intent(DISPLAY_MESSAGE_ACTION); intent.putExtra("rid", rid); intent.putExtra("journeyId", journeyId); intent.putExtra("type", notifType); intent.putExtra("message", (Utils.isEmptyOrNull(message)) ? "" : message); getApplicationContext().sendBroadcast(intent); } catch (Exception ex) { return; } Intent notifIntent = new Intent("com.smart.taxi.beep"); notifIntent.putExtra("msg", (Utils.isEmptyOrNull(message)) ? "Beep recevied" : message); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); //Define sound URI Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(getString(R.string.app_name)) .setStyle(new NotificationCompat.InboxStyle().addLine(msg.toString())).setContentText(message) .setSound(soundUri).setDefaults(Notification.DEFAULT_VIBRATE); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(rid, mBuilder.build()); }
From source file:android.example.com.squawker.fcm.SquawkFirebaseMessageService.java
/** * Create and show a simple notification containing the received FCM message * * @param data Map which has the message data in it *//*from w w w . j a v a 2 s. c o m*/ private void sendNotification(Map<String, String> data) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Create the pending intent to launch the activity PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); String author = data.get(JSON_KEY_AUTHOR); String message = data.get(JSON_KEY_MESSAGE); // If the message is longer than the max number of characters we want in our // notification, truncate it and add the unicode character for ellipsis if (message.length() > NOTIFICATION_MAX_CHARACTERS) { message = message.substring(0, NOTIFICATION_MAX_CHARACTERS) + "\u2026"; } Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_duck) .setContentTitle(String.format(getString(R.string.notification_message), author)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }