Example usage for android.app PendingIntent FLAG_UPDATE_CURRENT

List of usage examples for android.app PendingIntent FLAG_UPDATE_CURRENT

Introduction

In this page you can find the example usage for android.app PendingIntent FLAG_UPDATE_CURRENT.

Prototype

int FLAG_UPDATE_CURRENT

To view the source code for android.app PendingIntent FLAG_UPDATE_CURRENT.

Click Source Link

Document

Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent.

Usage

From source file:com.amazon.cordova.plugin.ADMMessageHandler.java

/**
 * Creates a notification when app is not running or is not in foreground. It puts the message info into the Intent
 * extra/* w ww .  j a v a  2 s  .  c  o  m*/
 * 
 * @param context
 * @param extras
 */
public void createNotification(Context context, Bundle extras) {
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    String appName = getAppName(this);

    // reuse the intent so that we can combine multiple messages into extra
    if (notificationIntent == null) {
        notificationIntent = new Intent(this, ADMHandlerActivity.class);
    }
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("pushBundle", extras);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    final Builder notificationBuilder = new Notification.Builder(context);
    notificationBuilder.setSmallIcon(context.getApplicationInfo().icon).setWhen(System.currentTimeMillis())
            .setContentIntent(contentIntent);

    if (this.shouldShowMessageInNotification()) {
        String message = extras.getString(PushPlugin.MESSAGE);
        notificationBuilder.setContentText(Html.fromHtml(message).toString());
    } else {
        notificationBuilder.setContentText(this.defaultMessageTextInNotification());
    }

    String title = appName;
    notificationBuilder.setContentTitle(title).setTicker(title);
    notificationBuilder.setAutoCancel(true);
    // Because the ID remains unchanged, the existing notification is updated.
    notificationManager.notify((String) appName, NOTIFICATION_ID, notificationBuilder.getNotification());
}

From source file:com.android.mms.transaction.ReadRecTransaction.java

public void run() {
    MmsLog.d(MmsApp.TXN_TAG, "ReadRecTransaction: process()");
    // prepare for ReadRec
    int readReportState = 0;
    String messageId = null;/*from   ww  w. j  a  va  2 s  .  c om*/
    long msgId = 0;
    EncodedStringValue[] sender = new EncodedStringValue[1];
    Cursor cursor = null;
    cursor = SqliteWrapper.query(mContext, mContext.getContentResolver(), mUri,
            new String[] { Mms.MESSAGE_ID, Mms.READ_REPORT, Mms._ID }, null, null, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                messageId = cursor.getString(0);
                readReportState = cursor.getInt(1);
                msgId = cursor.getLong(2);
            }
            // if curosr==null, this means the mms is deleted during
            // processing.
            // exception will happened. catched by out catch clause.
            // so do not catch exception here.
        } finally {
            cursor.close();
        }
    }
    MmsLog.d(MmsApp.TXN_TAG,
            "messageid:" + messageId + ",and readreport flag:" + readReportState + ", mSubId = " + mSubId);

    cursor = null;
    cursor = SqliteWrapper.query(mContext, mContext.getContentResolver(),
            Uri.parse("content://mms/" + msgId + "/addr"), new String[] { Mms.Addr.ADDRESS, Mms.Addr.CHARSET },
            Mms.Addr.TYPE + " = " + PduHeaders.FROM, null, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                String address = cursor.getString(0);
                int charSet = cursor.getInt(1);
                MmsLog.d(MmsApp.TXN_TAG, "find address:" + address + ",charset:" + charSet);
                sender[0] = new EncodedStringValue(charSet, PduPersister.getBytes(address));
            }
            // if cursor == null exception will catched by out catch clause.
        } finally {
            cursor.close();
        }
    }
    try {
        ReadRecInd readRecInd = new ReadRecInd(
                new EncodedStringValue(PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.getBytes()),
                messageId.getBytes(), PduHeaders.CURRENT_MMS_VERSION, PduHeaders.READ_STATUS_READ, // always
                // set
                // read.
                sender);
        readRecInd.setDate(System.currentTimeMillis() / 1000);
        Uri uri = PduPersister.getPduPersister(mContext).persist(readRecInd, Mms.Outbox.CONTENT_URI, true,
                MmsPreferenceActivity.getIsGroupMmsEnabled(mContext), null);

        byte[] datas = new PduComposer(mContext, readRecInd).make();
        mPduFile = createPduFile(datas, READREP_REQ_NAME + uri.getLastPathSegment());
        if (mPduFile == null) {
            Log.e(MmsApp.TXN_TAG, "create pdu file req failed!");
            return;
        }
        //Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED);
        //intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);
        //intent.putExtra(TransactionBundle.URI, mUri.toString());
        Log.d(MmsApp.TXN_TAG, "ReadRecTransaction mUri:" + mUri);
        final Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED, mUri, mContext,
                MmsReceiver.class);
        intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);

        PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, mPduFile);
        SmsManager.getSmsManagerForSubscriptionId(mSubId).sendMultimediaMessage(mContext, pduFileUri, null,
                null, sentIntent);
    } catch (InvalidHeaderValueException e) {
        Log.e(TAG, "Invalide header value", e);
        getState().setState(FAILED);
        getState().setContentUri(mUri);
        notifyObservers();
    } catch (MmsException e) {
        Log.e(TAG, "Persist message failed", e);
        getState().setState(FAILED);
        getState().setContentUri(mUri);
        notifyObservers();
    } catch (Throwable t) {
        Log.e(TAG, Log.getStackTraceString(t));
        getState().setState(FAILED);
        getState().setContentUri(mUri);
        notifyObservers();
    }
}

From source file:com.adam.aslfms.service.ScrobblingService.java

@Override
public int onStartCommand(Intent i, int flags, int startId) {
    handleCommand(i, startId);//from  w ww .j a v a2s.  co  m
    if (settings.isOnGoingEnabled(Util.checkPower(mCtx))) {
        if (mCurrentTrack != null) {
            String ar = mCurrentTrack.getArtist();
            String tr = mCurrentTrack.getTrack();
            String api = mCurrentTrack.getMusicAPI().readAPIname();

            // Heart intent
            Intent heartIntent = new Intent(mCtx, ScrobblingService.class);
            heartIntent.setAction(ScrobblingService.ACTION_HEART);
            PendingIntent heartPendingIntent = PendingIntent.getService(mCtx, 0, heartIntent, 0);
            NotificationCompat.Action heartAction = new NotificationCompat.Action.Builder(
                    R.mipmap.ic_status_wail_love_track, "", heartPendingIntent).build();

            Intent targetIntent = new Intent(mCtx, SettingsActivity.class);
            PendingIntent contentIntent = PendingIntent.getActivity(mCtx, 0, targetIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(mCtx).setContentTitle(tr)
                    .setSmallIcon(R.mipmap.ic_notify).setContentText(ar + " :" + api)
                    .setPriority(NotificationCompat.PRIORITY_MIN).addAction(heartAction)
                    .setContentIntent(contentIntent);

            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
                builder.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher));
            }

            this.startForeground(14619, builder.build());

            if (!settings.isNotifyEnabled(Util.checkPower(mCtx))) {
                Intent iNoti = new Intent(mCtx, ForegroundHide.class);
                startService(iNoti);
            }
        }
    } else {
        this.stopForeground(true); // TODO: test if this conflicts/stops scrobbles
    }
    return Service.START_STICKY;
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.service.OrgSyncService.java

private void notifyError() {
    NotificationCompat.Builder notBuilder = new NotificationCompat.Builder(this)
            // TODO hardcoded
            .setContentTitle("Could not access files").setContentText("Please change directory")
            .setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, PrefsActivity.class),
                    PendingIntent.FLAG_UPDATE_CURRENT));

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify(237388, notBuilder.build());
}

From source file:com.nbempire.dentalnavarra.component.service.RemembersService.java

private void showNotification(String title, String text, Remember remember) {
    Log.d(TAG, "Building notification...");

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notification).setContentTitle(title).setContentText(text)
            .setAutoCancel(true);//from w  ww  . j  av a 2  s . co m

    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(this, DentalNavarraActivity.class);
    if (remember != null) {
        Log.i(TAG, "Adding extra parameter to notification result intent, message: " + remember.getMessage());
        resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_MESSAGE, remember.getMessage());
        Log.i(TAG, "Adding extra parameter to notification result intent, meetingDate: "
                + remember.getMeetingDate());
        resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_MEETING_DATE, remember.getMeetingDate());
        Log.i(TAG, "Adding extra parameter to notification result intent, treatments: "
                + remember.getTreatments());
        resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_TREATMENTS, remember.getTreatments());
    }

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(DentalNavarraActivity.class);

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);

    Notification notification = mBuilder.build();
    notification.defaults |= Notification.DEFAULT_ALL;

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

    // mId allows you to update the notification later on.
    //  TODO : Functionality : Should I unhard-code this ID?
    mNotificationManager.notify(44, notification);

    Log.d(TAG, "Notification added to status bar: " + text);
}

From source file:com.android.email_ee.NotificationController.java

/**
 * Returns a {@link android.support.v4.app.NotificationCompat.Builder} for an event with the
 * given account. The account contains specific rules on ring tone usage and these will be used
 * to modify the notification behaviour.
 *
 * @param accountId The id of the account this notification is being built for.
 * @param ticker Text displayed when the notification is first shown. May be {@code null}.
 * @param title The first line of text. May NOT be {@code null}.
 * @param contentText The second line of text. May NOT be {@code null}.
 * @param intent The intent to start if the user clicks on the notification.
 * @param largeIcon A large icon. May be {@code null}
 * @param number A number to display using {@link Builder#setNumber(int)}. May be {@code null}.
 * @param enableAudio If {@code false}, do not play any sound. Otherwise, play sound according
 *        to the settings for the given account.
 * @return A {@link Notification} that can be sent to the notification service.
 *//*from   w  ww  .  j  a  v  a2 s .c  om*/
private NotificationCompat.Builder createBaseAccountNotificationBuilder(long accountId, String ticker,
        CharSequence title, String contentText, Intent intent, Bitmap largeIcon, Integer number,
        boolean enableAudio, boolean ongoing) {
    // Pending Intent
    PendingIntent pending = null;
    if (intent != null) {
        pending = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    // NOTE: the ticker is not shown for notifications in the Holo UX
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setContentTitle(title)
            .setContentText(contentText).setContentIntent(pending).setLargeIcon(largeIcon)
            .setNumber(number == null ? 0 : number).setSmallIcon(R.drawable.stat_notify_email)
            .setWhen(mClock.getTime()).setTicker(ticker).setOngoing(ongoing);

    if (enableAudio) {
        Account account = Account.restoreAccountWithId(mContext, accountId);
        setupSoundAndVibration(builder, account);
    }

    return builder;
}

From source file:com.android.providers.downloads.DownloadNotifier.java

private void updateWithLocked(Collection<DownloadInfo> downloads) {
    final Resources res = mContext.getResources();

    // Cluster downloads together
    final Multimap<String, DownloadInfo> clustered = ArrayListMultimap.create();
    for (DownloadInfo info : downloads) {
        final String tag = buildNotificationTag(info);
        if (tag != null) {
            clustered.put(tag, info);//from  ww  w .j  a  v a  2  s . c om
        }
    }

    // Build notification for each cluster
    for (String tag : clustered.keySet()) {
        final int type = getNotificationTagType(tag);
        final Collection<DownloadInfo> cluster = clustered.get(tag);

        final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);

        // Use time when cluster was first shown to avoid shuffling
        final long firstShown;
        if (mActiveNotifs.containsKey(tag)) {
            firstShown = mActiveNotifs.get(tag);
        } else {
            firstShown = System.currentTimeMillis();
            mActiveNotifs.put(tag, firstShown);
        }
        builder.setWhen(firstShown);

        // Show relevant icon
        if (type == TYPE_ACTIVE) {
            builder.setSmallIcon(android.R.drawable.stat_sys_download);
        } else if (type == TYPE_WAITING) {
            builder.setSmallIcon(android.R.drawable.stat_sys_warning);
        } else if (type == TYPE_COMPLETE) {
            builder.setSmallIcon(android.R.drawable.stat_sys_download_done);
        }

        // Build action intents
        if (type == TYPE_ACTIVE || type == TYPE_WAITING) {
            // build a synthetic uri for intent identification purposes
            final Uri uri = new Uri.Builder().scheme("active-dl").appendPath(tag).build();
            final Intent intent = new Intent(Constants.ACTION_LIST, uri, mContext, DownloadReceiver.class);
            intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS, getDownloadIds(cluster));
            builder.setContentIntent(
                    PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
            builder.setOngoing(true);

        } else if (type == TYPE_COMPLETE) {
            final DownloadInfo info = cluster.iterator().next();
            final Uri uri = ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, info.mId);
            builder.setAutoCancel(true);

            final String action;
            if (Downloads.Impl.isStatusError(info.mStatus)) {
                action = Constants.ACTION_LIST;
            } else {
                if (info.mDestination != Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION) {
                    action = Constants.ACTION_OPEN;
                } else {
                    action = Constants.ACTION_LIST;
                }
            }

            final Intent intent = new Intent(action, uri, mContext, DownloadReceiver.class);
            intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS, getDownloadIds(cluster));
            builder.setContentIntent(
                    PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));

            final Intent hideIntent = new Intent(Constants.ACTION_HIDE, uri, mContext, DownloadReceiver.class);
            builder.setDeleteIntent(PendingIntent.getBroadcast(mContext, 0, hideIntent, 0));
        }

        // Calculate and show progress
        String remainingText = null;
        String percentText = null;
        if (type == TYPE_ACTIVE) {
            long current = 0;
            long total = 0;
            long speed = 0;
            synchronized (mDownloadSpeed) {
                for (DownloadInfo info : cluster) {
                    if (info.mTotalBytes != -1) {
                        current += info.mCurrentBytes;
                        total += info.mTotalBytes;
                        speed += mDownloadSpeed.get(info.mId);
                    }
                }
            }

            if (total > 0) {
                final int percent = (int) ((current * 100) / total);
                percentText = res.getString(R.string.download_percent, percent);

                if (speed > 0) {
                    final long remainingMillis = ((total - current) * 1000) / speed;
                    remainingText = res.getString(R.string.download_remaining,
                            //                                DateUtils.formatDuration(remainingMillis)); // FIXME 
                            "" + remainingMillis);
                }

                builder.setProgress(100, percent, false);
            } else {
                builder.setProgress(100, 0, true);
            }
        }

        // Build titles and description
        final Notification notif;
        if (cluster.size() == 1) {
            final DownloadInfo info = cluster.iterator().next();

            builder.setContentTitle(getDownloadTitle(res, info));

            if (type == TYPE_ACTIVE) {
                if (!TextUtils.isEmpty(info.mDescription)) {
                    builder.setContentText(info.mDescription);
                } else {
                    builder.setContentText(remainingText);
                }
                builder.setContentInfo(percentText);

            } else if (type == TYPE_WAITING) {
                builder.setContentText(res.getString(R.string.notification_need_wifi_for_size));

            } else if (type == TYPE_COMPLETE) {
                if (Downloads.Impl.isStatusError(info.mStatus)) {
                    builder.setContentText(res.getText(R.string.notification_download_failed));
                } else if (Downloads.Impl.isStatusSuccess(info.mStatus)) {
                    builder.setContentText(res.getText(R.string.notification_download_complete));
                }
            }

            notif = builder.build();

        } else {
            final NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(builder);

            for (DownloadInfo info : cluster) {
                inboxStyle.addLine(getDownloadTitle(res, info));
            }

            if (type == TYPE_ACTIVE) {
                builder.setContentTitle(
                        res.getQuantityString(R.plurals.notif_summary_active, cluster.size(), cluster.size()));
                builder.setContentText(remainingText);
                builder.setContentInfo(percentText);
                inboxStyle.setSummaryText(remainingText);

            } else if (type == TYPE_WAITING) {
                builder.setContentTitle(
                        res.getQuantityString(R.plurals.notif_summary_waiting, cluster.size(), cluster.size()));
                builder.setContentText(res.getString(R.string.notification_need_wifi_for_size));
                inboxStyle.setSummaryText(res.getString(R.string.notification_need_wifi_for_size));
            }

            notif = inboxStyle.build();
        }

        mNotifManager.notify(tag, 0, notif);
    }

    // Remove stale tags that weren't renewed
    final Iterator<String> it = mActiveNotifs.keySet().iterator();
    while (it.hasNext()) {
        final String tag = it.next();
        if (!clustered.containsKey(tag)) {
            mNotifManager.cancel(tag, 0);
            it.remove();
        }
    }
}

From source file:com.android.email.NotificationController.java

/**
 * Returns a {@link android.support.v4.app.NotificationCompat.Builder} for an event with the
 * given account. The account contains specific rules on ring tone usage and these will be used
 * to modify the notification behaviour.
 *
 * @param accountId The id of the account this notification is being built for.
 * @param ticker Text displayed when the notification is first shown. May be {@code null}.
 * @param title The first line of text. May NOT be {@code null}.
 * @param contentText The second line of text. May NOT be {@code null}.
 * @param intent The intent to start if the user clicks on the notification.
 * @param largeIcon A large icon. May be {@code null}
 * @param number A number to display using {@link Builder#setNumber(int)}. May be {@code null}.
 * @param enableAudio If {@code false}, do not play any sound. Otherwise, play sound according
 *        to the settings for the given account.
 * @return A {@link Notification} that can be sent to the notification service.
 *//*w ww  .  j  a v  a  2  s. c  o m*/
private NotificationCompat.Builder createBaseAccountNotificationBuilder(long accountId, String ticker,
        CharSequence title, String contentText, Intent intent, Bitmap largeIcon, Integer number,
        boolean enableAudio, boolean ongoing) {
    // Pending Intent
    PendingIntent pending = null;
    if (intent != null) {
        pending = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    Account account = Account.restoreAccountWithId(mContext, accountId);

    int iconResId = NotifyIconUtilities.findNotifyIconForAccountDomain(mContext, R.drawable.stat_notify_email,
            account.mEmailAddress, R.drawable.stat_notify_email);
    // NOTE: the ticker is not shown for notifications in the Holo UX
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setContentTitle(title)
            .setContentText(contentText).setContentIntent(pending).setLargeIcon(largeIcon)
            .setNumber(number == null ? 0 : number).setSmallIcon(iconResId).setWhen(mClock.getTime())
            .setTicker(ticker).setOngoing(ongoing);

    if (enableAudio) {
        setupSoundAndVibration(builder, account);
    }

    return builder;
}

From source file:com.ibm.bluelist.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SensoroManager sensoroManager = SensoroManager.getInstance(getApplicationContext());
    blApplication = (MessengerApplication) getApplication();
    if (getIntent().getBooleanExtra("EXIT", false)) {
        finish();/*w  w  w . ja va 2  s  .c om*/
    }
    myIntent = new Intent(getApplicationContext(), PostTrackingNotifier.class);
    myIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);

    if (sensoroManager.isBluetoothEnabled()) {
        /**
         * Enable cloud service (upload sensor data, including battery status, UMM, etc.)Without setup, it keeps in closed status as default.
         **/
        sensoroManager.setCloudServiceEnable(true);
        /**
         * Enable SDK service
         **/
        try {
            sensoroManager.startService();
        } catch (Exception e) {
            e.printStackTrace(); // Fetch abnormal info
        }
    } else {
        Intent bluetoothIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(bluetoothIntent, REQUEST_ENABLE_BT);
    }
    BeaconManagerListener beaconManagerListener = new BeaconManagerListener() {
        ArrayList<String> foundSensors = new ArrayList<String>();

        @Override
        public void onUpdateBeacon(ArrayList<Beacon> beacons) {
            // Refresh sensor info
            for (Beacon beacon : beacons) {
                if (true) {
                    if (beacon.getMovingState() == Beacon.MovingState.DISABLED) {
                        // Disable accelerometer
                        System.out.println(beacon.getSerialNumber() + "Disabled");
                        Log.d("Main", beacon.getSerialNumber() + "Disabled");

                    } else if (beacon.getMovingState() == Beacon.MovingState.STILL) {
                        // Device is at static
                        Log.d("Main", beacon.getSerialNumber() + "static");
                        Log.d("Main", beacon.getProximityUUID());
                        if (!foundSensors.contains(beacon.getProximityUUID())) {
                            //String messageDisplay = "";
                            Log.d("Main", "getting Beacon Info");
                            foundSensors.add(beacon.getProximityUUID());
                            IBMCloudCode.initializeService();
                            IBMCloudCode myCloudCodeService = IBMCloudCode.getService();
                            String id = beacon.getProximityUUID();
                            String url = "/getNotification?id=" + id;
                            myCloudCodeService.get(url).continueWith(new Continuation<IBMHttpResponse, Void>() {

                                @Override
                                public Void then(Task<IBMHttpResponse> task) throws Exception {
                                    if (task.isCancelled()) {
                                        Log.e(CLASS_NAME,
                                                "Exception : Task" + task.isCancelled() + "was cancelled.");
                                    } else if (task.isFaulted()) {
                                        Log.e(CLASS_NAME, "Exception : " + task.getError().getMessage());
                                    } else {
                                        InputStream is = task.getResult().getInputStream();
                                        try {
                                            BufferedReader in = new BufferedReader(new InputStreamReader(is));
                                            String responseString = "";
                                            String myString = "";
                                            while ((myString = in.readLine()) != null)
                                                responseString += myString;

                                            in.close();
                                            Log.i(CLASS_NAME, "Response Body: " + responseString);
                                            JSONObject obj = new JSONObject(responseString);
                                            final String name = obj.getString("message");
                                            final String meets = obj.getString("meetups");

                                            /*Notification*/

                                            myIntent.putExtra("response", responseString);
                                            PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
                                                    getApplicationContext(), 5, myIntent,
                                                    PendingIntent.FLAG_UPDATE_CURRENT);
                                            final NotificationCompat.Builder builder = new NotificationCompat.Builder(
                                                    getApplicationContext());
                                            builder.setSmallIcon(R.drawable.logo);
                                            builder.setContentTitle("IBM Beacons Messenger");
                                            builder.setContentText(name);
                                            builder.setContentIntent(pendingNotificationIntent);
                                            NotificationManager notificationManager = (NotificationManager) getSystemService(
                                                    Context.NOTIFICATION_SERVICE);
                                            notificationManager.notify(5, builder.build());

                                        } catch (IOException e) {
                                            e.printStackTrace();
                                        }

                                        Log.i(CLASS_NAME, "Response Status from login: "
                                                + task.getResult().getHttpResponseCode());
                                    }

                                    return null;
                                }

                            });

                        }
                        Log.d("Main", beacon.getMajor().toString());
                        Log.d("Main", beacon.getMinor().toString());
                        //Log.d("Main",beacon.getRssi().toString());
                        System.out.println(beacon.getSerialNumber() + "static");

                    } else if (beacon.getMovingState() == Beacon.MovingState.MOVING) {
                        // Device is moving
                        Log.d("Main", beacon.getSerialNumber() + "moving");
                        Log.d("Main", beacon.getProximityUUID());
                        System.out.println(beacon.getSerialNumber() + "moving");
                    }
                }
            }
        }

        @Override
        public void onNewBeacon(Beacon beacon) {
            // New sensor found
            System.out.println(beacon.getSerialNumber());
            Log.d("Main", beacon.getSerialNumber() + "Got New");
        }

        @Override
        public void onGoneBeacon(Beacon beacon) {
            // A sensor disappears from the range
            System.out.println(beacon.getSerialNumber());

        }
    };
    sensoroManager.setBeaconManagerListener(beaconManagerListener);
}