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.studio.kartuimunisasi.utils.gcm.GCMListenerService.java
/** * Create and show a simple notification containing the received GCM message. *//*from ww w .j a v a 2 s .co m*/ private void sendNotification(String message) { 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_stat_ic_notification) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("GCM Message").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:app.com.locationfetch.GeofenceTransitionsIntentService.java
private void sendNotification(String s) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, 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("Location Push").setContentText(s) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:com.kr.zenithcompany.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) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setContentTitle(getResources().getString(R.string.app_name)).setSmallIcon(R.mipmap.icon) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(UniqueID.getRandomNumber(1000), notificationBuilder.build()); }
From source file:com.android.anton.pushnotificationwithgcm.GCMUtil.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// w w w . j a v a 2s .c o m */ private void sendNotification(String message) { 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.ic_notification).setContentTitle("Live Document Translator") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); // int notificationCount = getSharedPreferences("Notification", MODE_PRIVATE).getInt("Count", 0); // notificationCount ++; // SharedPreferences.Editor editor = this.getSharedPreferences("Notification", MODE_PRIVATE).edit(); // editor.putInt("Count", notificationCount); // editor.commit(); // // boolean success = ShortcutBadger.applyCount(getApplicationContext(), notificationCount); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.lokesh.FCMNotification.plugin.MyFirebaseMessagingService.java
public void createNotification(Context context, RemoteMessage.Notification message) { saveNotificationOnSharedPreferences(message.getBody(), context); Intent intent = new Intent(this, FCMNotificationHandlerActivity.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(this.getApplicationInfo().icon).setContentTitle(message.getTitle()) .setContentText(message.getBody()).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.dnabuba.tacademy.abuband.GCM.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from ww w . ja v a 2 s . com*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, IntroActivity.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); // Uri defaultSoundUri= RingtoneManager.getDefaultUri(R.raw.alert_sound); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.icon).setContentTitle("").setContentText(message) .setAutoCancel(true) // .setVibrate(new long[]{1000, 1000, 1000}) // .setSound(defaultSoundUri) .setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.example.gcmproject.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w ww. jav a2 s . c om*/ */ private void sendNotification(String message, String code) { Intent intent = null; if (code.equals("1")) { // ? intent = new Intent(this, MainActivity.class); // } else if (code.equals("2")) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(message)); // ? ? message ? uri . } 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("GCM Message").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // GCM notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:fr.bmartel.android.iotf.app.BaseActivity.java
protected void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); sharedpreferences = getSharedPreferences(StorageConst.STORAGE_PROFILE, Context.MODE_PRIVATE); notifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); try {//from w w w . j a v a 2 s . c om Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); ringtone = RingtoneManager.getRingtone(getApplicationContext(), notification); } catch (Exception e) { e.printStackTrace(); ringtone = null; } screenLock = ((PowerManager) getSystemService(POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG"); }
From source file:com.twilio.android.quickstart.MyFcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// ww w.j av a 2s.c o m */ private void sendNotification(String pTitle, String message) { 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); String title = "FCM Message"; if (pTitle != null) { title = pTitle; } 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.tmendes.birthdaydroid.MessageNotification.java
public static void notify(final Context context, ContactData contact, String msgShareBody, boolean customMsg, long daysUntil) throws IOException { final Resources res = context.getResources(); String msgShareTitle;/*from w w w. j a v a 2 s .co m*/ if (contact.isThereAPartyToday()) { msgShareTitle = res.getString(R.string.message_notification_share_title); } else { msgShareTitle = res.getString(R.string.message_notification_bt_to_come_title); } if (contact.isThereAPartyToday()) { if ((!customMsg) || (msgShareBody.length() == 0)) { msgShareBody = res.getString(R.string.message_notification_share_body, contact.getContactFirstName()); } } else { msgShareBody = res.getString(R.string.message_notification_bt_to_come_share_body, contact.getContactFirstName()); } String notifyMsgBody; if (contact.isThereAPartyToday()) { if (contact.hasYear()) { notifyMsgBody = res.getString(R.string.message_notification_message, contact.getContactFirstName(), contact.getAge()); } else { notifyMsgBody = res.getString(R.string.message_notification_message_no_age, contact.getContactFirstName()); } } else { notifyMsgBody = res.getString(R.string.message_notification_message_bt_to_come, contact.getContactFirstName(), contact.getAge() + 1, daysUntil); } Bitmap notifyPicture; if (contact.getPhotoURI() != null) { Uri imageUri = Uri.parse(contact.getPhotoURI()); notifyPicture = MediaStore.Images.Media.getBitmap(context.getContentResolver(), imageUri); } else { notifyPicture = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_account_circle_white_24dp); } final String title = contact.getName(); final String text = notifyMsgBody; notificationId = title; final NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_cake_white_24dp).setContentTitle(title).setContentText(text) .setPriority(NotificationCompat.PRIORITY_DEFAULT).setLargeIcon(notifyPicture).setTicker(title) .setNumber(1).setSound(MessageNotification.notificationSound, RingtoneManager.TYPE_NOTIFICATION) .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW, Uri.parse(ContactsContract.Contacts.CONTENT_LOOKUP_URI + "/" + contact.getKey())), PendingIntent.FLAG_UPDATE_CURRENT)) .setStyle(new NotificationCompat.BigTextStyle().bigText(text).setBigContentTitle(title)) .addAction(R.drawable.ic_share_white_24dp, res.getString(R.string.message_notification_action), PendingIntent.getActivity(context, 0, Intent.createChooser(new Intent(Intent.ACTION_SEND).setType("text/plain") .putExtra(Intent.EXTRA_TEXT, msgShareBody), msgShareTitle), PendingIntent.FLAG_UPDATE_CURRENT)) .setAutoCancel(true); notify(context, builder.build()); }