Example usage for android.app Notification DEFAULT_SOUND

List of usage examples for android.app Notification DEFAULT_SOUND

Introduction

In this page you can find the example usage for android.app Notification DEFAULT_SOUND.

Prototype

int DEFAULT_SOUND

To view the source code for android.app Notification DEFAULT_SOUND.

Click Source Link

Document

Use the default notification sound.

Usage

From source file:nu.yona.app.ui.YonaActivity.java

private void showDeviceRestartNotification(final String message) {
    Intent intent = new Intent(Intent.ACTION_REBOOT);
    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

    Notification notification = new Notification.Builder(this).setContentTitle(getString(R.string.appname))
            .setContentText(message).setTicker(getString(R.string.appname)).setWhen(0)
            .setVibrate(new long[] { 1, 1, 1 }).setDefaults(Notification.DEFAULT_SOUND)
            .setStyle(new Notification.BigTextStyle().bigText(message)).setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
            .setContentIntent(pIntent).setAutoCancel(false).build();

    notification.flags |= Notification.FLAG_NO_CLEAR;

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(0, notification);
}

From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java

final static private void showMessageNotification(TaskManagerParms taskMgrParms, EnvironmentParms envParms,
        CommonUtilities util, TaskResponse tr, String m_text, int led_color, int led_on, int led_off) {
    NotificationManager nm = (NotificationManager) taskMgrParms.context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder nb = new NotificationCompat.Builder(taskMgrParms.context);
    nm.cancel("MSG", taskMgrParms.msgNotificationId);
    Intent in = new Intent();
    PendingIntent pi = PendingIntent.getActivity(taskMgrParms.context, 0, in,
            PendingIntent.FLAG_CANCEL_CURRENT);
    pi.cancel();/*from   ww  w .j a va2s  .  c  o m*/
    nb.setContentIntent(pi).setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)
            .setOngoing(false).setAutoCancel(true).setSmallIcon(R.drawable.action)
            .setContentTitle(taskMgrParms.context.getString(R.string.app_name)).setContentText(m_text)
            .setWhen(System.currentTimeMillis());
    if (led_color != 0)
        nb.setLights(led_color, led_on, led_off);
    Notification nf = nb.build();
    nm.notify("MSG", taskMgrParms.msgNotificationId, nf);
    synchronized (envParms) {
        if (taskMgrParms.msgNotificationId >= MAX_NOTIFICATION_COUNT)
            taskMgrParms.msgNotificationId = 1;
        else
            taskMgrParms.msgNotificationId++;
    }
}