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:com.josetomastocino.siteupclient.app.GcmIntentService.java

private void sendNotification(String msg) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, LoginActivity.class), 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_siteup).setContentTitle("SiteUp Notification")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE).setContentText(msg);

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

From source file:com.becapps.easydownloader.utils.Utils.java

public static void setNotificationDefaults(NotificationCompat.Builder aBuilder) {
    String def = settings.getString("notification_defaults", "0");
    if (def.equals("0")) {
        aBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
    }// www .  j  ava  2 s  . com
    if (def.equals("1")) {
        aBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS);
    }
    if (def.equals("2")) {
        aBuilder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
    }
    if (def.equals("3")) {
        aBuilder.setDefaults(Notification.DEFAULT_ALL);
    }
    if (def.equals("4")) {
        aBuilder.setDefaults(Notification.DEFAULT_SOUND);
    }
    if (def.equals("5")) {
        aBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }
    if (def.equals("6")) {
        aBuilder.setDefaults(Notification.DEFAULT_LIGHTS);
    }
    if (def.equals("7")) {
        // nothing...
    }
}

From source file:com.herokuapp.pushdemoandroid.GcmIntentService.java

private void sendNotification(String msg) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle("GCM Notification")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg);

    mBuilder.setContentIntent(contentIntent);
    mBuilder.setDefaults(// www .j a v a  2s .  c o  m
            Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:com.endiansoftware.echo.remotewatch.GcmIntentService.java

private void sendNotification(Bundle msg) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(msg.get("key1").toString())
            .setContentText(msg.get("key2").toString()).setTicker(msg.get("key1").toString());

    mBuilder.setContentIntent(contentIntent);
    Notification notification = mBuilder.build();

    if (msg.get("collapse_key").toString().equals("Emergency")) {
        notification.flags |= notification.FLAG_INSISTENT | notification.FLAG_AUTO_CANCEL;
        notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS;
        notification.vibrate = new long[] { 100L, 100L, 200L, 500L };
    } else {/*from   w  ww . j a va  2  s  .  com*/
        notification.flags |= notification.FLAG_AUTO_CANCEL;
        notification.defaults |= Notification.DEFAULT_LIGHTS;
        notification.vibrate = new long[] { 100L };
    }
    mNotificationManager.notify(NOTIFICATION_ID, notification);
    PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
            "TAG");
    wl.acquire();
}

From source file:com.tenmiles.helpstack.service.AttachmentDownloadReceiver.java

private void downloadCompleted(Context context, Intent intent) {
    StringBuilder text = new StringBuilder();
    //Files are  ready
    String filename = context.getString(R.string.hs_attachment);
    String filepath = null;//from   w  w w  .jav a 2 s .c  o  m
    String mediaType = null;
    DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
    long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
    Query query = new Query();
    query.setFilterById(downloadId);
    Cursor c = dm.query(query);
    if (c.moveToFirst()) {
        int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
        filename = c.getString(c.getColumnIndex(DownloadManager.COLUMN_TITLE));
        filepath = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
        mediaType = c.getString(c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE));
        if (status == DownloadManager.STATUS_SUCCESSFUL) {
            text.append(context.getString(R.string.hs_download_complete));

        } else {
            text.append(context.getString(R.string.hs_error_during_download));
        }
    }

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

    NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(context);
    notificationbuilder.setAutoCancel(true);
    notificationbuilder.setContentText(text.toString());
    notificationbuilder.setContentTitle(filename);
    notificationbuilder.setSmallIcon(R.drawable.hs_notification_download_img);
    notificationbuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
    notificationbuilder.setContentIntent(getPendingIntent(context));

    notificationManager.notify(filename, NOTIFICATION_ID, notificationbuilder.build());
}

From source file:ru.appsm.inapphelp.service.AttachmentDownloadReceiver.java

private void downloadCompleted(Context context, Intent intent) {
    StringBuilder text = new StringBuilder();
    //Files are  ready
    String filename = context.getString(R.string.iah_attachment);
    String filepath = null;// w  w w.j a v  a 2 s.c  om
    String mediaType = null;
    DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
    long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
    Query query = new Query();
    query.setFilterById(downloadId);
    Cursor c = dm.query(query);
    if (c.moveToFirst()) {
        int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
        filename = c.getString(c.getColumnIndex(DownloadManager.COLUMN_TITLE));
        filepath = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
        mediaType = c.getString(c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE));
        if (status == DownloadManager.STATUS_SUCCESSFUL) {
            text.append(context.getString(R.string.iah_download_complete));

        } else {
            text.append(context.getString(R.string.iah_error_during_download));
        }
    }

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

    NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(context);
    notificationbuilder.setAutoCancel(true);
    notificationbuilder.setContentText(text.toString());
    notificationbuilder.setContentTitle(filename);
    notificationbuilder.setSmallIcon(R.drawable.iah_notification_download_light_img);
    notificationbuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
    notificationbuilder.setContentIntent(getPendingIntent(context));

    notificationManager.notify(filename, NOTIFICATION_ID, notificationbuilder.build());
}

From source file:com.procasy.dubarah_nocker.gcm.MyGcmPushReceiver.java

/**
 * Called when message is received./*w  w  w  . j a v  a 2s .c o  m*/
 *
 * @param from   SenderID of the sender.
 * @param bundle Data bundle containing message data as key/value pairs.
 *               For Set of keys use data.keySet().
 */

@Override
public void onMessageReceived(String from, Bundle bundle) {

    MainActivity.getInstance().updateNotification();

    try {

        Log.e("notify_gcm", "success , type = " + bundle.toString());

        switch (bundle.getString(GCM_TAG)) {
        case "GENERAL": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, GENERAL_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }

        case "HELP": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, HELP_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            JSONObject content = new JSONObject(bundle.getString("content"));
            JSONObject hr = content.getJSONObject("hr");
            JSONArray album = content.getJSONArray("album");
            System.out.println(content.getInt("hr_id"));
            System.out.println(content.toString());
            Bundle bundle1 = new Bundle();
            bundle1.putString("hr_id", hr.getString("hr_id"));
            bundle1.putString("hr_user_id", hr.getString("hr_user_id"));
            bundle1.putString("hr_description", hr.getString("hr_description"));
            bundle1.putString("hr_est_date", hr.getString("hr_est_date"));
            bundle1.putString("hr_est_time", hr.getString("hr_est_time"));
            bundle1.putString("hr_skill_id", hr.getString("hr_skill_id"));
            bundle1.putString("hr_ua_id", hr.getString("hr_ua_id"));
            bundle1.putString("hr_voice_record", hr.getString("hr_voice_record"));
            bundle1.putString("hr_language", hr.getString("hr_language"));
            bundle1.putString("hr_lat", hr.getString("hr_lat"));
            bundle1.putString("hr_lon", hr.getString("hr_lon"));
            bundle1.putString("hr_address", hr.getString("hr_address"));
            ArrayList<String> array = new ArrayList<>();
            for (int i = 0; i < album.length(); i++) {
                JSONObject object = album.getJSONObject(i);
                array.add(object.getString("ahr_img"));
            }
            bundle1.putStringArrayList("album", array);

            Intent intent = (new Intent(getApplicationContext(), JobRequestActivity.class));
            intent.putExtras(bundle1);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            getApplicationContext().startActivity(intent);

            break;
        }

        case "APPOINTEMENT": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, APPOINTEMENT_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }

        case "QOUTA_USER": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, USER_Qouta_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }

        case "QOUTA_NOCKER": {
            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG))
                    .setContentText(bundle.getString(DESC_TAG));
            Intent resultIntent = new Intent(this, MainActivity.class);
            TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            mBuilder.setDefaults(
                    Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
            NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                    Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(12, mBuilder.build());
            mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext());
            mNotification.open();
            try {
                ContentValues contentValues = new ContentValues();
                contentValues.put(mNotification.COL_notification_type, Nocker_Qouta_TAG);
                contentValues.put(mNotification.COL_notfication_status, 0);
                contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG));
                contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG));
                contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG));
                mNotification.insertEntry(contentValues);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                mNotification.close();
            }
            break;
        }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.example.mego.adas.accidents.fcm.ADASFirebaseMessageService.java

/**
 * Create and show a accident notification containing the received FCM message
 *
 * @param longitude     accident longitude
 * @param latitude      accident latitude
 * @param accidentState accident state true if the accident update location , false if new accident
 * @param title         the accident title
 *///from ww w  .j  a  v  a2 s . c  o m

private void sendAccidentNotification(Context context, double longitude, double latitude, boolean accidentState,
        String title) {

    //Check if new accident or updated one
    String notificationText = "An accident occurred at longitude: " + longitude + " and latitude: " + latitude;
    if (accidentState) {
        notificationText = "An accident location changed to longitude: " + longitude + " and latitude: "
                + latitude;
    }

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary)).setSmallIcon(R.mipmap.ic_launcher)
            .setLargeIcon(NotificationUtils.largeIcon(context)).setContentTitle(title)
            .setContentText(notificationText)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationText))
            .setDefaults(Notification.DEFAULT_VIBRATE).setDefaults(Notification.DEFAULT_SOUND)
            .setContentIntent(contentIntent(context, longitude, latitude)).setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
    }

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

    notificationManager.notify(ADAS_ACCIDENT_FCM_NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.unlockdisk.android.opengl.MainGLActivity.java

public void generateNotification(int id, String notificationTitle, String notificationMessage) {
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.ic_launcher, "A New Message!",
            System.currentTimeMillis());

    Intent notificationIntent = new Intent(this, MainGLActivity.class);
    // Intent notificationIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.setLatestEventInfo(MainGLActivity.this, notificationTitle, notificationMessage, pendingIntent);

    //Setting Notification Flags
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.flags |= Notification.DEFAULT_SOUND;
    //Adding the Custom Sound
    notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
    String uri = "android.resource://org.openmobster.notify.android.app/"
            + MainGLActivity.this.findSoundId(MainGLActivity.this, "beep");
    notification.sound = Uri.parse(uri);
    //  notification.sound = Uri.fromFile(new File(R.raw.a));
    notificationManager.notify(id, notification);
}

From source file:com.fastbootmobile.rssdemo.PushReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "ACTION : " + intent.getAction()); // Debug log the intent "action"

    // Get the shared preferences for OwnPush keys
    SharedPreferences pref = context.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH,
            Context.MODE_PRIVATE);

    if (intent.getAction().equals(OwnPushClient.INTENT_RECEIVE)) {

        // This is a push message

        Log.d(TAG, "Decrypt : " + intent.getExtras().getString(OwnPushClient.EXTRA_DATA));

        OwnPushCrypto fp = new OwnPushCrypto(); // Create a crypto object for decrypt

        // Get the app key pair from shared preferences (these have been confirmed by the register intent)
        OwnPushCrypto.AppKeyPair keys = fp.getKey(pref.getString(OwnPushClient.PREF_PUBLIC_KEY, ""),
                pref.getString(OwnPushClient.PREF_PRIVATE_KEY, ""));

        // Decrypt the message from the intent extra data
        String msg = fp.decryptFromIntent(intent.getExtras(), BuildConfig.APP_PUBLIC_KEY, keys);

        JSONObject jObj;/*  ww  w . j av a 2 s.co  m*/
        if (msg != null) {
            Log.e(TAG, "RSS : " + msg);

            try {
                // Decode the JOSN data in the message
                jObj = new JSONObject(msg);

                Intent i = new Intent(Intent.ACTION_VIEW); // Create the intent
                i.setData(Uri.parse(jObj.getString("link"))); // Set the data using URI (these are web links)

                // Convert to pending intent
                PendingIntent pIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), i,
                        0);

                // Create the notification
                Notification n = new Notification.Builder(context.getApplicationContext())
                        .setContentTitle("OwnPush RSS") // Main Title
                        .setContentText(jObj.getString("title")) // Set content
                        .setContentIntent(pIntent) // Add the pending intent
                        .setSmallIcon(R.drawable.ic_done).setAutoCancel(true) // Remove notification if opened
                        .build();

                n.defaults |= Notification.DEFAULT_SOUND; // Make some noise on push

                // Get the notification manager and display notification
                NotificationManager notificationManager = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                notificationManager.notify(notification_num, n);

                // Increase the notification counter by 1
                notification_num++;

            } catch (Exception e) {
                return;
            }

        }
    }
}