Example usage for android.media RingtoneManager getDefaultUri

List of usage examples for android.media RingtoneManager getDefaultUri

Introduction

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

Prototype

public static Uri getDefaultUri(int type) 

Source Link

Document

Returns the Uri for the default ringtone of a particular type.

Usage

From source file:com.achep.acdisplay.ui.activities.MainActivity.java

private static void sendTestNotification(@NonNull Context context) {
    final int id = App.ID_NOTIFY_TEST;
    final Resources res = context.getResources();

    PendingIntent pendingIntent = PendingIntent.getActivity(context, id,
            new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle()
            .bigText(res.getString(R.string.notification_test_message_large));
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(res.getString(R.string.app_name))
            .setContentText(res.getString(R.string.notification_test_message)).setContentIntent(pendingIntent)
            .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher))
            .setSmallIcon(R.drawable.stat_acdisplay).setAutoCancel(true).setStyle(bts)
            .setColor(App.ACCENT_COLOR)/*from w  w  w  . j ava  2  s.co  m*/
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(id, builder.build());
}

From source file:biz.atelecom.communicator.MyGcmListenerService.java

private void sendNotification(Bundle data) {
    //Intent intent = new Intent(this, ChatActivity.class);
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtras(data);/*  ww w.j  a  v a2s .c om*/

    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.atelecom_ic_notification).setContentTitle("Atelecom 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.unfc.choicecustomercaretb.gcmservices.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM
 * message./*from w  ww.  j av  a  2  s  . co m*/
 *
 * @param message
 *            GCM message received.
 */
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, intent, PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.app_icon).setContentTitle("Your request has been accepted!!")
            .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify((int) new Date().getTime(), notificationBuilder.build());
}

From source file:com.syncano.gcmsample.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./* w ww.  jav a 2 s.  c o  m*/
 */
private void showNotification(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_icon).setContentTitle(getString(R.string.notification_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.bullmobi.message.ui.activities.MainActivity.java

private static void sendTestNotification(@NonNull Context context) {
    final int id = App.ID_NOTIFY_TEST;
    final Resources res = context.getResources();

    PendingIntent pendingIntent = PendingIntent.getActivity(context, id,
            new Intent(context, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.BigTextStyle bts = new NotificationCompat.BigTextStyle()
            .bigText(res.getString(R.string.notification_test_message_large));
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(res.getString(R.string.app_name))
            .setContentText(res.getString(R.string.notification_test_message)).setContentIntent(pendingIntent)
            .setLargeIcon(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher))
            .setSmallIcon(R.drawable.stat_easynotification).setAutoCancel(true).setStyle(bts)
            .setColor(App.ACCENT_COLOR)//from   w ww  .  j  a v a 2  s  . com
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(id, builder.build());
}

From source file:com.example.fiveguys.trip_buddy_v0.fcm.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *///from   w  w w . ja v  a2  s  . com
public static void sendNotification(Context context, String messageBody, String channelUrl) {
    Intent intent = new Intent(context, com.example.fiveguys.trip_buddy_v0.main.ChatActivity.class);
    intent.putExtra("groupChannelUrl", channelUrl);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 /* Request code */, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle(context.getResources().getString(R.string.app_name)).setContentText(messageBody)
            .setAutoCancel(true).setSound(defaultSoundUri).setPriority(Notification.PRIORITY_MAX)
            .setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent);

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

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

From source file:bhtech.com.cabbydriver.services.MyGcmListenerService.java

private void sendNotification(String message) {
    Intent intent = new Intent(this, ChooseRouteToCustomerController.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.demo.push.GcmListener.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*  w  w  w .j  av a2  s  . com*/
 */
private void sendNotification(String message) {

    Intent intent = new Intent(this, LandingActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 0);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(getResources().getString(R.string.app_name))
            .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:ar.uba.fi.splitapp.MockServer.java

private static void showNotification(String header, String message, Bitmap icon) {

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(appContext)
            .setSmallIcon(R.drawable.logo).setLargeIcon(MockServer.getCircleBitmap(icon))
            .setContentTitle(header).setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
            .setColor(appContext.getResources().getColor(R.color.colorPrimaryLight));

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

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

From source file:com.demo.android.smsapp.receivers.SMSReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    final Bundle bundle = intent.getExtras();

    try {//from ww w.  j  av  a2  s  . c om

        if (bundle != null) {
            NotificationManager notificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);

            final Object[] pdusObj = (Object[]) bundle.get("pdus");

            for (int i = 0; i < pdusObj.length; i++) {

                SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                String phoneNumber = currentMessage.getDisplayOriginatingAddress();

                String message = currentMessage.getDisplayMessageBody();

                Intent chatActivityIntent = new Intent(context, SMSChatActivity.class);
                chatActivityIntent.putExtra("number", phoneNumber);
                PendingIntent pi = PendingIntent.getActivity(context, 1, chatActivityIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);

                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(phoneNumber).setContentText(message)
                        .setContentIntent(pi)
                        .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

                notificationManager.notify(99, mBuilder.build());

                Log.i("SmsReceiver", "senderNum: " + phoneNumber + "; message: " + message);

            }
        }

    } catch (Exception e) {
        Log.e("SmsReceiver", "Exception smsReceiver" + e);

    }
}