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.mx.example1.gcm.MyGcmListenerService.java

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_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:com.eeec.GestionEspresso.gcm.KGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.// w ww  .  ja v  a  2s. co m
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, SplashActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_notification).setColor(getResources().getColor(R.color.colorPrimary))
            .setContentText(message).setContentTitle("Gestin Espresso").setAutoCancel(true)
            .setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}

From source file:com.radioyps.gcm_test.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from   w ww .  j  a v  a  2s  .c om*/
 */
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_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:adapter.notification.MyFcmListenerService.java

private void sendNotification(RemoteMessage.Notification notification) {
    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_utn).setContentTitle(notification.getTitle())
            .setContentText(notification.getBody()).setGroup(notification.getTag()).setAutoCancel(true)
            .setColor(ContextCompat.getColor(getApplicationContext(), R.color.caldroid_holo_blue_dark))
            .setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

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

From source file:com.schantz.mydls.activity.registration.MyGcmListenerService.java

/**
 * Called when message is received.//from   w  w w.j  a v a 2s  .  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().
 */
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");
    String policyId = data.getString("policyId");
    String documentId = data.getString("documentId");

    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);
    Log.d(TAG, "PolicyId: " + policyId);
    Log.d(TAG, "documentId: " + documentId);

    Intent intent = new Intent(this, DocumentActivity.class);
    intent.putExtra("documentId", documentId);
    intent.putExtra("policyId", policyId);
    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.drawable.schantz_logo).setContentTitle("Document received").setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

    notificationManager.notify(0, notificationBuilder.build());
}

From source file:com.example.rasel.firstfirebaseproject.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *
 * @param remoteMessage FCM RemoteMessage received.
 *///from w ww .j  av a2 s .  c o  m
private void sendNotification(RemoteMessage remoteMessage) {

    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);

    // this is a my insertion looking for a solution
    int icon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.clkbtn : R.mipmap.ic_launcher;
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setSmallIcon(icon)
            .setContentTitle(remoteMessage.getFrom()).setContentText(remoteMessage.getNotification().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.awt.supark.ParkingTimerService.java

public void onCreate() {
    super.onCreate();
    Log.i("Service", "---------- Service created ----------");

    notificationManager = (NotificationManager) getApplicationContext()
            .getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
    soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
}

From source file:com.pimp.instincts.MyFirebaseMessagingService.java

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage.getData().size() > 0) {
        Log.e("FCM", "Message data payload: " + remoteMessage.getData());
    }//from  w  w  w.  j a  va2 s  . c om

    Intent intent = new Intent(this, HomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("google.sent_time", remoteMessage.getSentTime());
    intent.putExtra("from", remoteMessage.getFrom());
    intent.putExtra("google.message_id", remoteMessage.getMessageId());
    intent.putExtra("collapse_key", remoteMessage.getCollapseKey());
    for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
        intent.putExtra(entry.getKey(), entry.getValue());
    }
    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.drawable.ic_stat_ic_notification)
            .setColor(Color.parseColor(remoteMessage.getData().get("color")))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getData().get("content")))
            .setContentTitle(remoteMessage.getData().get("title"))
            .setContentText(remoteMessage.getData().get("content"))
            .setTicker(remoteMessage.getData().get("content")).setAutoCancel(true).setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

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

    notificationManager.notify(0, notificationBuilder.build());
}

From source file:com.miappgcm.appfactory.MiGcmListenerService.java

private void MostrarNotification(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_notificacion).setContentTitle("GCM Message").setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

    int idNotificacion = 1;
    notificationManager.notify(1, notificationBuilder.build());
}

From source file:com.lumi_dos.lge.MyGcmListenerService.java

private void sendNotification(Bundle data) {
    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 = data.getString("title");
    String body = data.getString("body");
    Context context = this;
    Bitmap large_icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.launcher);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.launcher).setLargeIcon(large_icon).setContentTitle(title)
            .setContentText(body).setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent)
            .setPriority(NotificationCompat.PRIORITY_HIGH);

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

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