Example usage for android.media RingtoneManager TYPE_NOTIFICATION

List of usage examples for android.media RingtoneManager TYPE_NOTIFICATION

Introduction

In this page you can find the example usage for android.media RingtoneManager TYPE_NOTIFICATION.

Prototype

int TYPE_NOTIFICATION

To view the source code for android.media RingtoneManager TYPE_NOTIFICATION.

Click Source Link

Document

Type that refers to sounds that are used for notifications.

Usage

From source file:com.leo.cattle.presentation.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//  w  w w  .ja  va 2s .com
 */
private void sendNotification(Bundle bundle) {
    String message = bundle.getString("message");
    Intent intent = new Intent(this, SignInActivity.class);
    Bundle b = new Bundle();
    //b.putString("username", AndroidApplication.sessionUser.getFullName());
    b.putString("to", bundle.getString("username"));
    b.putString("session_id", bundle.getString("chatSessionId"));
    b.putString("type", bundle.getString("type"));
    intent.putExtras(b);
    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_whats_hot).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:com.teamappjobs.appjobs.FCM.MyFirebaseMessagingService.java

/**
 * Create and show notification containing the received FCM message.
 *
 * @param messageBody FCM message body received.
 *///from   w  w w  .  j av a 2 s.  c  o  m
private void onNovaPromocao(String messageBody) {
    VitrineJson vitrineJson = new VitrineJson();
    Promocao promocao = vitrineJson.JsonToPromocao(messageBody);

    //  Intent intent = new Intent(this, MainActivity.class);
    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra("From", "notifyFragSigo");

    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);
    long[] v = { 100, 500, 100, 500 }; //Vibrao
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)

            .setSmallIcon(R.drawable.heart_notif).setContentTitle(promocao.getNome())
            .setContentText(promocao.getDescricao()).setAutoCancel(true).setSound(defaultSoundUri).setVibrate(v)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:com.fitticket.model.services.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from w  w w  .  j a v  a2 s.c  o  m
 * @param type
 */
private void sendNotification(String message, String type) {
    Intent intent;
    if (!TextUtils.isEmpty(type) && type.equalsIgnoreCase("confirmation")) {
        intent = new Intent(this, MainActivity.class);
        intent.putExtra(MainActivity.SHOW_UPCOMING, true);
    } else {
        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.fit).setContentTitle(getString(R.string.app_name))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(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:com.iems5722.group9.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from  w w  w  .  j a  v a2 s.c  om*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, com.iems5722.group9.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.q).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:com.example.chinz_000.silverchef.MyFcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from  w w  w. jav a2  s.co  m
 */
private void sendNotification(String pTitle, String message) {
    Intent intent = new Intent(this, NotifyActivity.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.excilys.voisinsenor.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./* w  w  w . j  av a 2  s  .c o m*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, HomeActivity.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("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:com.derekma.videogallery.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from   w  w w . j ava 2s.c  o m*/
 */
private void sendNotification(String message, String id, String title) {

    Intent intent = new Intent(this, PlayerActivity.class);
    intent.putExtra("videoId", id);

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    /**
     * Different type of PendingIntent
     * FLAG_CANCEL_CURRENT
     * FLAG_NO_CREATE
     * FLAG_ONE_SHOT
     * FLAG_UPDATE_CURRENT
     */
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    Bitmap btm = BitmapFactory.decodeResource(getResources(), R.drawable.paw_heart);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.paw_heart_small).setContentTitle(title).setContentText(message)
            .setAutoCancel(true).setLargeIcon(btm).setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:com.example.prueba.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from  ww  w  .  j  a v  a2  s  .  c  o m
 */
private void sendNotification(String message, String user, String time, String men, String hr) {
    Intent intent = new Intent(this, Confirmacion.class);
    intent.putExtra("user", user);
    intent.putExtra("time", time);
    intent.putExtra("hr", hr);
    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.book).setContentTitle("Biblioteca").setContentText(men).setAutoCancel(true)
            .setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:azzaoui.sociadee.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from   ww w . j a  va2s. 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.pp_swag).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:com.rajat.e_subzi.gcm.MyGcmListenerService.java

private void sendNotification(String message) {
    Intent intent = new Intent(this, NotificationView.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.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
    //        bigText.bigText(message);
    //        bigText.setBigContentTitle("eSubzi");

    //bigText.setSummaryText("By: Dhaval Sodha Parmar");

    //        RemoteViews remoteViews = new RemoteViews(getPackageName(),
    //                R.layout.custom_notification);
    //        Intent resultIntent = new Intent(this, Login.class);
    //        // The stack builder object will contain an artificial back stack for
    //        // the
    //        // started Activity.
    //        // This ensures that navigating backward from the Activity leads out of
    //        // your application to the Home screen.
    //        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    //        // Adds the back stack for the Intent (but not the Intent itself)
    //        stackBuilder.addParentStack(Login.class);
    //        // Adds the Intent that starts the Activity to the top of the stack
    //        stackBuilder.addNextIntent(resultIntent);
    ///////////////////////
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.bag).setContentTitle("eSubzi").setContentText(message)
            //.setContent()
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
    //notificationBuilder.setStyle(bigText);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(id++, notificationBuilder.build());

}