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.zaparound.MyFirebaseMessagingService.java

/**
 * Create and show a Inmylocation Notification.
 *
 * @param messageBody FCM message body received.
 *///from  ww w .j a  va  2s. co  m
private void sendNotificationInmylocation(String messagetitle, String messageBody) {
    Intent intent = new Intent(this, LandingActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("CHATTAB_POSITION", 3);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
    Notification notification = mBuilder.setSmallIcon(R.drawable.applogo).setTicker(messagetitle).setWhen(0)
            .setAutoCancel(true).setContentTitle(messagetitle)
            //.setNumber(++count)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
            //.setSubText("\n "+count+" new messages\n")
            .setContentIntent(pendingIntent)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.applogo))
            .setContentText(messageBody).build();

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

From source file:com.sender.team.sender.gcm.MyGcmListenerService.java

private void sendNotification(String message) {
    Intent intent = new Intent(this, AcceptActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    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).setTicker("SENDER").setContentTitle("SENDER")
            .setContentText("? ").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.gm.goldencity.util.Utils.java

/**
 * Play notification sound/*from w  w w. j  a  v  a2s. c  o m*/
 *
 * @param context Application context
 */
public static void playNotificationSound(Context context) {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(context, notification);
    r.play();
}

From source file:com.xorcode.andtweet.PreferencesActivity.java

protected void showRingtone(Object newValue) {
    String ringtone = (String) newValue;
    Uri uri;//from w  w  w .  j a  v a2  s.  c  o  m
    Ringtone rt;
    if (ringtone == null) {
        uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    } else if ("".equals(ringtone)) {
        mNotificationRingtone.setSummary(R.string.summary_preference_no_ringtone);
    } else {
        uri = Uri.parse(ringtone);
        rt = RingtoneManager.getRingtone(this, uri);
        mNotificationRingtone.setSummary(rt.getTitle(this));
    }
}

From source file:com.piggeh.palmettoscholars.services.MyFirebaseMessagingService.java

public void notifyUndefined(String title, String text) {
    Intent contentIntent = new Intent(this, MainActivity.class);
    //contentIntent.putExtra("navigation_page", MainActivity.PAGE_ANNOUNCEMENTS);
    contentIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, contentIntent,
            PendingIntent.FLAG_ONE_SHOT);

    Intent settingsIntent = new Intent(this, MainActivity.class);
    settingsIntent.putExtra("navigation_page", MainActivity.PAGE_SETTINGS);
    settingsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent settingsPendingIntent = PendingIntent.getActivity(this, 1 /* Request code */, settingsIntent,
            PendingIntent.FLAG_ONE_SHOT);

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

    NotificationCompat.BigTextStyle notifStyle = new NotificationCompat.BigTextStyle();
    notifStyle.bigText(text);/*from  ww  w.  j a v  a 2 s .co m*/
    notifStyle.setBigContentTitle(title);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notification_icon_nodpi).setContentTitle(title).setContentText(text)
            .setAutoCancel(true).setSound(defaultSoundUri)
            .setColor(ContextCompat.getColor(this, R.color.colorPrimary)).setContentIntent(contentPendingIntent)
            .setStyle(notifStyle);

    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

    // Build the notification and issues it with notification manager.
    notificationManager.notify(NOTIFICATION_ID_UNDEFINED, notificationBuilder.build());
}

From source file:com.example.jendrik.moerder.FCM.MyFcmListenerService.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 .  co m
 */
private void sendNotification(String message) {
    //TODO wie baue ich die jeweilige Activity ein?
    //ist so schon richtig. Nur eben mit der richtigen Klasse. Anschlieend den Intent starten "startActivity(intent);"
    //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());
}

From source file:com.sender.team.sender.gcm.MyGcmListenerService.java

private void sendRejectNotification() {
    Intent intent = new Intent(this, SplashActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(ACTION_REJECT, "reject");
    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).setTicker("SENDER").setContentTitle("SENDER")
            .setContentText("?  ?").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.nbplus.vbroadlistener.gcm.MyGcmListenerService.java

private void showNotification(Context context, int notificationId, int smallIconId, String title,
        String contentText, String bigTitle, String bigContentText, String summaryText, String ticker,
        Intent intent) {/*from   w w w.j  a v a  2s . c om*/
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setSound(soundUri);

    if (smallIconId == 0) {
        builder.setSmallIcon(R.mipmap.ic_launcher);
    } else {
        builder.setSmallIcon(smallIconId);
    }
    builder.setWhen(System.currentTimeMillis());
    //builder.setNumber(10);

    if (!StringUtils.isEmptyString(ticker)) {
        builder.setTicker(ticker);
    }

    if (StringUtils.isEmptyString(title)) {
        builder.setContentTitle(PackageUtils.getApplicationName(context));
    } else {
        builder.setContentTitle(title);
    }
    builder.setContentText(contentText);
    builder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
    builder.setAutoCancel(true);

    // big title and text
    if (!StringUtils.isEmptyString(bigTitle) && !StringUtils.isEmptyString(bigContentText)) {
        NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle(builder);
        if (!StringUtils.isEmptyString(summaryText)) {
            style.setSummaryText(summaryText);
        }
        style.setBigContentTitle(bigTitle);
        style.bigText(bigContentText);

        builder.setStyle(style);
    }

    if (intent != null) {
        intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationId, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        builder.setContentIntent(pendingIntent);
    }

    notificationManager.notify(notificationId, builder.build());
}

From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java

@Subscribe
public void syncStopped(SyncStopped event) {
    TextView tvRecv = (TextView) findViewById(R.id.tvReceived);
    TextView tvRecvWarning = (TextView) findViewById(R.id.tvReceivedWarningAmount);
    final WalletAccount selectedAccount = _mbwManager.getSelectedAccount();
    final List<TransactionSummary> transactionsSince = selectedAccount.getTransactionsSince(_receivingSince);
    final ArrayList<TransactionSummary> interesting = new ArrayList<TransactionSummary>();
    CurrencyValue sum = ExactBitcoinValue.ZERO;
    for (TransactionSummary item : transactionsSince) {
        if (item.toAddresses.contains(_address)) {
            interesting.add(item);//from w  w  w .  j  a v  a2 s.  c  o m
            sum = item.value;
        }
    }

    if (interesting.size() > 0) {
        tvRecv.setText(getString(R.string.incoming_payment)
                + Utils.getFormattedValueWithUnit(sum, _mbwManager.getBitcoinDenomination()));
        // if the user specified an amount, also check it if it matches up...
        if (!CurrencyValue.isNullOrZero(_amount)) {
            tvRecvWarning.setVisibility(sum.equals(_amount) ? View.GONE : View.VISIBLE);
        } else {
            tvRecvWarning.setVisibility(View.GONE);
        }
        tvRecv.setVisibility(View.VISIBLE);
        if (!sum.equals(_lastAddressBalance)) {
            NotificationManager notificationManager = (NotificationManager) this
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
                    .setSound(soundUri, AudioManager.STREAM_NOTIFICATION); //This sets the sound to play
            notificationManager.notify(0, mBuilder.build());

            _lastAddressBalance = sum;
        }
    } else {
        tvRecv.setVisibility(View.GONE);
    }
}

From source file:com.piggeh.palmettoscholars.services.MyFirebaseMessagingService.java

public void notifyUndefined(String title, String text, String URL) {
    Uri webpage = Uri.parse(URL);
    Intent contentIntent = new Intent(Intent.ACTION_VIEW, webpage);
    PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, contentIntent,
            PendingIntent.FLAG_ONE_SHOT);

    Intent settingsIntent = new Intent(this, MainActivity.class);
    settingsIntent.putExtra("navigation_page", MainActivity.PAGE_SETTINGS);
    settingsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent settingsPendingIntent = PendingIntent.getActivity(this, 1 /* Request code */, settingsIntent,
            PendingIntent.FLAG_ONE_SHOT);

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

    NotificationCompat.BigTextStyle notifStyle = new NotificationCompat.BigTextStyle();
    notifStyle.bigText(text);/*from w ww.j  a v a2s. c  o m*/
    notifStyle.setBigContentTitle(title);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notification_icon_nodpi).setContentTitle(title).setContentText(text)
            .setAutoCancel(true).setSound(defaultSoundUri)
            .setColor(ContextCompat.getColor(this, R.color.colorPrimary)).setContentIntent(contentPendingIntent)
            .setStyle(notifStyle);

    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

    // Build the notification and issues it with notification manager.
    notificationManager.notify(NOTIFICATION_ID_UNDEFINED, notificationBuilder.build());
}