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.ghosthawk.salard.GCM.MyGcmListenerService.java
private void sendNotification(String message) { Intent intent = new Intent(this, SellHomeActivity.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) .setTicker("Salard ").setSmallIcon(R.drawable.rating_bar_full) .setContentTitle("Salard ? ?.").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.whereismyfriend.GcmIntentService.java
private void sendNotification(String msg, String badge, String type) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); int notification_id; PendingIntent contentIntent;/*from w w w . j a va2 s.co m*/ if (type.compareTo("s") == 0) { contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Solicitudes.class), 0); notification_id = 0; } else { contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Mapa.class), 0); notification_id = 1; } if (Integer.parseInt(badge) > 1) { if (type.compareTo("s") == 0) msg = getResources().getString(R.string.push_no_leidas_1) + " " + badge + " " + getResources().getString(R.string.push_no_leidas_2); else msg = getResources().getString(R.string.push_no_leidas_1_acc) + " " + badge + " " + getResources().getString(R.string.push_no_leidas_2_acc); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(getResources().getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .setAutoCancel(true); AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); switch (am.getRingerMode()) { case AudioManager.RINGER_MODE_SILENT: mBuilder.setLights(Color.CYAN, 3000, 3000); break; case AudioManager.RINGER_MODE_VIBRATE: mBuilder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); mBuilder.setLights(Color.CYAN, 3000, 3000); break; case AudioManager.RINGER_MODE_NORMAL: mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); mBuilder.setLights(Color.CYAN, 3000, 3000); break; } mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(notification_id, mBuilder.build()); }
From source file:com.getmarco.weatherstationviewer.gcm.StationGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w . ja v a 2s . c om*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, StationListActivity.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.ic_launcher).setContentTitle("Station update").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.lovespectre.lwin.message.services.IMService.java
/** * Show a notification while this service is running. * * @param msg/* ww w. java2 s. c o m*/ */ private void showNotification(String username, String msg) { // Set the icon, scrolling text and TIMESTAMP String title = "AndroidIM: You got a new Message! (" + username + ")"; String text = username + ": " + ((msg.length() < 5) ? msg : msg.substring(0, 5) + "..."); //NotificationCompat.Builder notification = new NotificationCompat.Builder(R.drawable.stat_sample, title,System.currentTimeMillis()); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_message_black_24dp).setContentTitle(title).setContentText(text) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); Intent i = new Intent(this, Messaging.class); i.putExtra(FriendInfo.USERNAME, username); i.putExtra(MessageInfo.MESSAGETEXT, msg); // The PendingIntent to launch our activity if the user selects this notification PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0); // Set the info for the views that show in the notification panel. // msg.length()>15 ? MSG : msg.substring(0, 15); mBuilder.setContentIntent(contentIntent); mBuilder.setContentText("New message from " + username + ": " + msg); //TODO: it can be improved, for instance message coming from same user may be concatenated // next version // Send the notification. // We use a layout id because it is a unique number. We use it later to cancel. mNM.notify((username + msg).hashCode(), mBuilder.build()); }
From source file:com.poguico.palmabici.network.synchronizer.NetworkStationAlarm.java
public void showNotification(Station station) { SharedPreferences mPrefs;/*from w w w . j a va 2s .c o m*/ SharedPreferences.Editor edit; String message = Formatter.formatBikesAvailableMessage(context, station); Bitmap bigIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.palmabici_bw); Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.bike) .setLargeIcon(bigIcon).setContentTitle("PalmaBici").setContentText(message) .setLights(0x0000ff00, 1000, 1000).setTicker(message).setSound(uri).setAutoCancel(true); NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mBuilder.setContentIntent(pendingIntent); mPrefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); edit = mPrefs.edit(); edit.putInt(PREFS_SHOWN_STATION, station.getId()); edit.commit(); mgr.notify(0, mBuilder.build()); }
From source file:com.popdeem.sdk.core.gcm.GCMIntentService.java
private void sendNotification(String title, String message, PendingIntent pendingIntent, int id) { Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_pd_notification).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(id, notificationBuilder.build()); }
From source file:com.preguardia.app.notification.MyGcmListenerService.java
private void showMessageNewNotification(String title, String message, String consultationId) { // Prepare intent which is triggered if the notification is selected Intent intent = new Intent(this, ConsultationDetailsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(Constants.EXTRA_CONSULTATION_ID, consultationId); PendingIntent pendingIntent = PendingIntent.getActivity(this, Constants.GENERAL_NEW_MESSAGE_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_logo).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(Constants.NOTIFICATION_NEW_MESSAGE_ID, notificationBuilder.build()); }
From source file:app.androidhive.info.realm.GCM.GcmIntentService.java
private void sendNotification(String title, String msg, String link) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); /* Intent intent = new Intent(this, MainActivity.class); intent.putExtra("phone", link);/*from ww w. j av a2 s . c o m*/ PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);*/ Phone = link; // getData(link); Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class); dialogIntent.putExtra("Phone", link); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplication().startActivity(dialogIntent); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setLargeIcon(BitmapFactory.decodeResource(getBaseContext().getResources(), R.mipmap.ic_launcher)) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(link).setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); // Set the notification vibrate option if (preferences.getBoolean("notifications_new_message_vibrate", true)) { mBuilder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); } // Set the notification ringtone if (preferences.getString("notifications_new_message_ringtone", null) != null) { mBuilder.setSound(Uri.parse(preferences.getString("notifications_new_message_ringtone", null))); } else { Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); } // Show only if the notification are enabled if (preferences.getBoolean("notifications_new_message", true)) { // mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
From source file:com.cityfreqs.littlesirecho.MainActivity.java
private void initLittleSirEcho() { IntentFilter filter = new IntentFilter(); filter.addAction(LISTENER_STRING);/*w w w . j a va2 s .c o m*/ LSEsr = new LSEServiceReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(LSEsr, new IntentFilter(LISTENER_STRING)); soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); setAwakeView(); startHourPicker = (NumberPicker) findViewById(R.id.start_hour_picker); startHourPicker.setMinValue(0); startHourPicker.setMaxValue(11); startHourPicker.setValue(DEFAULT_AWAKE_START); startHourPicker.setWrapSelectorWheel(false); // stop numpad auto appearing startHourPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); // set listener here instead of implementing at activity level startHourPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { if (picker == startHourPicker) { if (newVal != userAwakeStart) { userAwakeStart = newVal; setAwakeView(); } } } }); endHourPicker = (NumberPicker) findViewById(R.id.end_hour_picker); endHourPicker.setMinValue(12); endHourPicker.setMaxValue(23); endHourPicker.setValue(DEFAULT_AWAKE_END); endHourPicker.setWrapSelectorWheel(false); // stop numpad auto appearing endHourPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); // set listener here instead of implementing at activity level endHourPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { if (picker == endHourPicker) { if (newVal != userAwakeEnd) { userAwakeEnd = newVal; setAwakeView(); } } } }); }
From source file:cl.telematica.android.alimentame.GeofenceTransitionsIntentService.java
/** * Posts a notification in the notification bar when a transition is detected. * If the user clicks the notification, control goes to the MainActivity. *//*from w ww . jav a 2s.c o m*/ private void sendNotification(String notificationDetails) { // Create an explicit content Intent that starts the main Activity. Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class); // Construct a task stack. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Add the main Activity to the task stack as the parent. stackBuilder.addParentStack(MainActivity.class); // Push the content Intent onto the stack. stackBuilder.addNextIntent(notificationIntent); // Get a PendingIntent containing the entire back stack. PendingIntent notificationPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); // Get a notification builder that's compatible with platform versions >= 4 NotificationCompat.Builder builder = new NotificationCompat.Builder(this); // Define the notification settings. builder.setSmallIcon(R.mipmap.ic_launcher) // In a real app, you may want to use a library like Volley // to decode the Bitmap. .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setColor(Color.RED).setContentTitle(notificationDetails) .setContentText(getString(R.string.geofence_transition_notification_text)) .setVibrate(new long[] { 100, 250, 100, 500 }) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentIntent(notificationPendingIntent); // Dismiss notification once the user touches it. builder.setAutoCancel(true); // Get an instance of the Notification manager NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // Issue the notification mNotificationManager.notify(0, builder.build()); }