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:GeofenceIntentService.java

private void sendNotification() {
    Log.i("GeofenceIntentService", "sendNotification()");
    Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Geofence Alert")
            .setContentText("GEOFENCE_TRANSITION_DWELL").setSound(notificationSoundUri)
            .setLights(Color.BLUE, 500, 500);
    NotificationManager notificationManager = (NotificationManager) getApplicationContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}

From source file:com.achep.acdisplay.notifications.NotificationHelper.java

@NonNull
public static Notification buildNotification(@NonNull Context context, final int id,
        @NonNull Object... objects) {
    final Resources res = context.getResources();
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.stat_acdisplay).setColor(App.ACCENT_COLOR).setAutoCancel(true);

    PendingIntent pi = null;/*from   w  w w .ja v  a2  s. c  o  m*/
    switch (id) {
    case App.ID_NOTIFY_TEST: {
        NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle()
                .bigText(res.getString(R.string.notification_test_message_large));
        builder.setStyle(bts).setContentTitle(res.getString(R.string.app_name))
                .setContentText(res.getString(R.string.notification_test_message))
                .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher))
                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        break;
    }
    case App.ID_NOTIFY_BATH: {
        CharSequence contentText = (CharSequence) objects[0];
        Intent contentIntent = (Intent) objects[1];
        // Build notification
        pi = PendingIntent.getActivity(context, id, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        builder.setContentTitle(res.getString(R.string.service_bath)).setContentText(contentText)
                .setPriority(Notification.PRIORITY_MIN);
        break;
    }
    case App.ID_NOTIFY_INIT: {
        builder.setSmallIcon(R.drawable.stat_notify).setContentTitle(res.getString(R.string.app_name))
                .setContentText(res.getString(R.string.notification_init_text))
                .setPriority(Notification.PRIORITY_MIN);
        break;
    }
    case App.ID_NOTIFY_APP_AUTO_DISABLED: {
        CharSequence summary = (CharSequence) objects[0];
        NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle()
                .bigText(res.getString(R.string.permissions_auto_disabled)).setSummaryText(summary);
        builder.setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher))
                .setContentTitle(res.getString(R.string.app_name))
                .setContentText(res.getString(R.string.permissions_auto_disabled))
                .setPriority(Notification.PRIORITY_HIGH).setStyle(bts);
        break;
    }
    default:
        throw new IllegalArgumentException();
    }
    if (pi == null) {
        pi = PendingIntent.getActivity(context, id, new Intent(context, MainActivity.class),
                PendingIntent.FLAG_UPDATE_CURRENT);
    }
    return builder.setContentIntent(pi).build();
}

From source file:com.gaj2l.eventtus.services.notifications.NotificationService.java

private void sendNotification(String title, String messageBody) {

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

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.eventtus).setColor(getResources().getColor(R.color.colorPrimary, null))
            .setContentTitle(title).setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri);

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

From source file:com.campusconnect.MyFirebaseMessagingService.java

@Override
public void onCreate() {
    defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    inboxStyle = new NotificationCompat.InboxStyle();
    super.onCreate();
    notificationBuilder = new NotificationCompat.Builder(this);

}

From source file:com.apptentive.android.example.push.MyGcmListenerService.java

@Override
public void onMessageReceived(String from, Bundle data) {
    String title = data.getString("gcm.notification.title");
    String body = data.getString("gcm.notification.body");
    ApptentiveLog.e("From: " + from);
    ApptentiveLog.e("Title: " + title);
    ApptentiveLog.e("Body: " + body);

    Intent intent = new Intent(this, ExampleActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Apptentive.setPendingPushNotification(data);

    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.notification).setContentTitle(title).setContentText(body)
            .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.fjoglar.etsitnoticias.view.notification.Notification.java

public static void createNotification(Context context) {
    if (needToNotify()) {

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);

        if (mNewsCount == 1) {
            NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
            bigTextStyle.bigText(mNotificationDesc.get(0))
                    .setSummaryText(context.getResources().getString(R.string.app_name));

            // Create the notification.
            mBuilder.setSmallIcon(R.drawable.ic_notification).setContentTitle(mNotificationText.get(0))
                    .setContentText(mNotificationDesc.get(0))
                    .setColor(context.getResources().getColor(R.color.colorPrimary))
                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                    .setAutoCancel(true).setStyle(bigTextStyle);
        } else {// www.  j a va2  s . c  o m
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            inboxStyle.setBigContentTitle(context.getResources().getString(R.string.app_name));
            inboxStyle.setSummaryText("Tienes " + mNewsCount + " noticias nuevas.");
            for (String notificationTxt : mNotificationText) {
                inboxStyle.addLine(notificationTxt);
            }

            // Create the notification.
            mBuilder.setSmallIcon(R.drawable.ic_notification)
                    .setContentTitle(context.getResources().getString(R.string.app_name))
                    .setContentText("Tienes " + mNewsCount + " noticias nuevas.")
                    .setColor(context.getResources().getColor(R.color.colorPrimary))
                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                    .setAutoCancel(true).setStyle(inboxStyle);
        }

        Intent resultIntent = new Intent(context, NewsListActivity.class);

        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);

        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(ETSIT_NEWS_NOTIFICATION_ID, mBuilder.build());
    }

    // Clear values for next notifications.
    mNewsCount = 0;
    mNotificationText.clear();
}

From source file:com.contactlab.clabpush_android_sample.GcmListenerService.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.drawable.notification_template_icon_bg).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.pg.app.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.drawable.ic_icon_info).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.github.piasy.taskdemo.NotificationUtil.java

private static NotificationCompat.Builder getCommonBuilder(Context context) {
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    long[] pattern = { 500, 500, 500, 500 };
    return new NotificationCompat.Builder(context).setSmallIcon(R.mipmap.ic_launcher).setSound(alarmSound)
            .setVibrate(pattern).setLights(Color.BLUE, 500, 500).setAutoCancel(true);
}

From source file:com.onsemi.matrix.android.pushnotification.PNGcmListenerService.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.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());
}