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:br.com.awa.mylottery.gcm.MyGcmListenerService.java

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

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.common_ic_googleplayservices).setContentTitle("MyLottery")
            .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.pixtory.app.pushnotification.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//w w w.  ja v  a2 s .c o  m
 */
private void sendNotification(String message, String image) {
    Intent intent = new Intent(this, HomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);
    Bitmap b = null;
    try {
        URL url = new URL(image);
        b = BitmapFactory.decodeStream(url.openConnection().getInputStream());
    } catch (Exception e) {
        e.printStackTrace();
    }
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.notif).setContentTitle("pixtory").setContentText(message)
            .setAutoCancel(true);

    //.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.pixtory))
    if (b != null)
        notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(b));

    notificationBuilder.setContentIntent(pendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    AmplitudeLog.logEvent(new AmplitudeLog.AppEventBuilder(App_Notification_Shown)
            .put(AppConstants.USER_ID, Utils.getUserId(getApplicationContext())).build());
    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:com.alobha.challenger.business.gmc.NotificationGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param challenge GCM challenge received.
 *///w w  w.j  av a2 s.co m
private void sendNotification(Challenge challenge) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("challenge_id", challenge.id);
    intent.setAction("ShowNotification");
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

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

    Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.inner_logo);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.inner_logo).setLargeIcon(largeIcon)
            .setContentTitle(getString(R.string.app_name))
            .setContentText("You were challenged by " + challenge.owner.first_name).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.example.karan.bookdemo.chat.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from  w w  w.  j a  va2 s .c  o  m
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, ChatList.class).putExtra("data", message).putExtra("sender", Sender);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, new Random().nextInt() /* Request code */,
            intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("From:" + Sender).setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

    notificationManager.notify(new Random().nextInt() /* ID of notification */, notificationBuilder.build());
}

From source file:com.neklo.demo.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//  ww w  . ja va2s .  com
 */
private void sendNotification(String title, 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(getApplication().getApplicationInfo().icon).setContentTitle(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:br.com.alquest.alquestdemo.app.Services.GcmIntentService.java

private void sendNotification(String type, String msg) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
    String title = "";
    Log.e(TAG, type);/*from   ww w.j  a  v  a2 s .  c  o  m*/
    if (type.contains("message")) {
        title = getResources().getString(R.string.new_message);
    }
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);

    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    long[] pattern = { 500, 500, 500, 500, 500, 500, 500, 500, 500 };
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setLights(0xFF0000FF, 100, 3000)
            .setVibrate(pattern).setSound(alarmSound).setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(title).setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
            .setContentText(msg);

    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:com.devbd.cttd.hello_ct.PushPkg.GcmBroadcastReceiver.java

private void sendNotification(Bundle bundle) {

    String msg = bundle.getString("price");

    System.out.println(">>>>>>>>>>FFFF  " + bundle.toString());

    //       String from_name=bundle.getString("From_Name");
    //       String type=bundle.getString("Type");
    //       String params=bundle.getString("Params");

    //       NotificationDetails nd=new NotificationDetails();
    //       nd.setBody(msg);
    //       nd.setFrom_email(from_email);
    //       nd.setFrom_name(from_name);
    //       nd.setFrom_image(from_image);
    //       //from   www.ja  va  2  s .  c o  m

    mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);

    // 
    if (msg != null) {

        Noti.msg = msg;
        PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, new Intent(ctx, Noti.class),
                PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx).setSmallIcon(R.mipmap.icon)
                .setLargeIcon(BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.icon))
                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                .setContentTitle(ctx.getResources().getString(R.string.app_name)).setAutoCancel(true)
                .setContentText(Html.fromHtml(msg))
                .setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(msg)));

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}

From source file:com.wondereight.sensioair.gcm.SAGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from  w w  w .  ja  va  2s.  com*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, HomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(Constant.NOTI_MESSAGE, message);
    int requestCode = new Random().nextInt(); //System.currentTimeMillis() / 1000;
    PendingIntent pendingIntent = PendingIntent.getActivity(this, requestCode /* Request code */, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle(getString(R.string.titleMessage)) //.setContentTitle("GCM Message")
            .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

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

    //        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    //        int count = Integer.valueOf( sharedPreferences.getString(SAPreferences.COUNT_MESSAGES, "0") );
    //        sharedPreferences.edit().putString(SAPreferences.COUNT_MESSAGES, String.valueOf(count+1)).apply();
    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); //notificationManager.notify(count /* ID of notification */, notificationBuilder.build());
}

From source file:com.appsaur.tarucassist.AlarmReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    int mReceivedID = Integer.parseInt(intent.getStringExtra(BaseActivity.EXTRA_REMINDER_ID));

    // Get notification title from Reminder Database
    ScheduleReminderDataSource scheduleReminderDataSource = new ScheduleReminderDataSource(context);
    StudentScheduleDataSource studentScheduleDataSource = new StudentScheduleDataSource(context);
    studentScheduleDataSource.open();//w  w w  . j  av a2  s  .c o  m
    ScheduleReminder scheduleReminder = scheduleReminderDataSource.getScheduleReminder(mReceivedID);
    String mTitle = scheduleReminder.getTitle();
    int scheduleId = scheduleReminder.getScheduleId();
    mCalendar = Calendar.getInstance();

    String scheduleDate = studentScheduleDataSource.getCancelledScheduleById(scheduleId,
            BaseActivity.dateFormat.format(mCalendar.getTime()));

    if (!scheduleDate.equals(""))
        mTitle = mTitle + " - Cancelled";

    // Create intent to open ReminderEditActivity on notification click
    Intent editIntent = new Intent(context, ViewScheduleActivity.class);
    editIntent.putExtra(BaseActivity.KEY_SCHEDULE_ID, Integer.toString(scheduleId));
    PendingIntent mClick = PendingIntent.getActivity(context, mReceivedID, editIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Create Notification
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
            .setSmallIcon(R.drawable.ic_timetable_white)
            .setContentTitle(context.getResources().getString(R.string.app_name)).setTicker(mTitle)
            .setContentText(mTitle).setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setContentIntent(mClick).setAutoCancel(true).setOnlyAlertOnce(true);

    NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nManager.notify(mReceivedID, mBuilder.build());

}

From source file:com.javathlon.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*ww  w.j av a  2 s  .c o m*/
 */
private void sendNotification(String title, String message, String type, String url) {
    Intent resultIntent = null;

    if (type.equals("podcast")) {
        resultIntent = new Intent(this, MainActivity.class);
        resultIntent.putExtra("needdownloaded", "y");
        resultIntent.putExtra("rss", url);
        resultIntent.putExtra("action", "rsslist");

    } else if (type.equals("web")) {
        resultIntent = new Intent(this, WebViewActivity.class);
        resultIntent.putExtra("url", url);

    }

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 1 /* Request code */, resultIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.controllers_play).setContentTitle(title).setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri)

            .setContentIntent(pendingIntent);

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

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

}