List of usage examples for android.app NotificationManager notify
public void notify(int id, Notification notification)
From source file:de.evilbrain.sendtosftp.Main.java
private void notificationSend(String Title, String Text) { PendingIntent pIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(this); Notification notification = notificationbuilder.setContentIntent(pIntent) .setSmallIcon(R.drawable.ic_launcher).setTicker(Title).setWhen(0).setAutoCancel(true) .setContentTitle(Title).setStyle(new NotificationCompat.BigTextStyle().bigText(Text)) .setContentText(Text).build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(notificationID, notification); notificationID++;// w w w . j a v a 2s .c o m }
From source file:de.electricdynamite.pasty.GCMIntentService.java
@SuppressLint("NewApi") @Override//www . j a va 2 s.c om protected void onMessage(Context context, Intent intent) { if (prefs == null) this.prefs = new PastyPreferencesProvider(context); final Bundle extras = intent.getExtras(); if (extras == null) { Log.i(TAG, "onMessage(): Empty intent received"); return; } final String mItemId = extras.getString("itemId"); final String mItemStr = extras.getString("item"); final int mEventId = Integer.parseInt(extras.getString("eventId")); if (mItemId == null || mItemStr == null || mItemId == "" || mItemStr == "") { Log.i(TAG, "onMessage(): Invalid intent received"); return; } if (LOCAL_LOG) Log.v(TAG, "onMessage(): Received message for event: " + mEventId); switch (mEventId) { case EVENT_ITEM_ADDED: final String lastItemId = prefs.getLastItem(); if (mItemId.equals(lastItemId)) return; if (client == null) { client = new PastyClient(prefs.getRESTBaseURL(), true); client.setUsername(prefs.getUsername()); client.setPassword(prefs.getPassword()); } final ClipboardItem mItem = new ClipboardItem(mItemId, mItemStr); final Boolean mPush = prefs.getPush(); final Boolean mCopyToClipboard = prefs.getPushCopyToClipboard(); final Boolean mNotify = prefs.getPushNotify(); if (mPush == true) { if (mCopyToClipboard == true) { if (mItem.getText() != "") { Intent resultIntent = new Intent(this, CopyService.class); resultIntent.putExtra("de.electricdynamite.pasty.itemId", mItem.getId()); resultIntent.putExtra("de.electricdynamite.pasty.item", mItem.getText()); resultIntent.putExtra("de.electricdynamite.pasty.notify", mNotify); startService(resultIntent); resultIntent = null; } } else { if (mNotify == true) { String contentText = String.format(getString(R.string.notification_event_add_text), mItem.getText()); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_pasty) .setContentTitle(getString(R.string.notification_event_add_title)) .setContentText(contentText).setAutoCancel(Boolean.TRUE); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, CopyService.class); resultIntent.putExtra("de.electricdynamite.pasty.itemId", mItem.getId()); resultIntent.putExtra("de.electricdynamite.pasty.item", mItem.getText()); resultIntent.putExtra("de.electricdynamite.pasty.notify", mNotify); PendingIntent resultPendingIntent = PendingIntent.getService(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(PastySharedStatics.NOTIFICATION_ID, mBuilder.build()); } } JSONArray clipboard = null; try { clipboard = client.getClipboard(); cacheClipboard(clipboard); } catch (PastyException e) { if (LOCAL_LOG) Log.v(TAG, "Could not get clipboard: " + e.getMessage()); } } break; default: Log.i(TAG, "onMessage(): Unsupported event: " + mEventId); break; } /* TODO Make ClipboardFragment react to changes from GCMIntentService */ }
From source file:com.bevyios.gcm.BevyGcmListenerService.java
private void sendNotification(Bundle bundle) { Resources resources = getApplication().getResources(); String packageName = getApplication().getPackageName(); Class intentClass = getMainActivityClass(); if (intentClass == null) { return;/*from ww w . ja va2s. co m*/ } if (applicationIsRunning()) { Intent i = new Intent("BevyGCMReceiveNotification"); i.putExtra("bundle", bundle); sendBroadcast(i); return; } int resourceId = resources.getIdentifier(bundle.getString("largeIcon"), "mipmap", packageName); Intent intent = new Intent(this, intentClass); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); //Bitmap largeIcon = BitmapFactory.decodeResource(resources, resourceId); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) //.setLargeIcon(largeIcon) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("title").setContentText("content") .setAutoCancel(false).setSound(defaultSoundUri) //.setTicker(bundle.getString("ticker")) .setCategory(NotificationCompat.CATEGORY_CALL).setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setPriority(NotificationCompat.PRIORITY_HIGH).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notif = notificationBuilder.build(); notif.defaults |= Notification.DEFAULT_VIBRATE; notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_LIGHTS; notificationManager.notify(0, notif); }
From source file:io.coldstart.android.GCMIntentService.java
private void sendBatchNotification(String batchCount) { if (null == batchCount) batchCount = "1+"; Intent intent = new Intent(this, TrapListActivity.class); intent.putExtra("forceDownload", true); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); Intent broadcastDownload = new Intent(); broadcastDownload.setAction(BatchDownloadReceiver.BROADCAST_ACTION); PendingIntent pBroadcastDownload = PendingIntent.getBroadcast(this, 0, broadcastDownload, 0); Intent broadcastIgnore = new Intent(); broadcastIgnore.setAction(BatchIgnoreReceiver.BROADCAST_ACTION); PendingIntent pBroadcastIgnore = PendingIntent.getBroadcast(this, 0, broadcastIgnore, 0); Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Notification notification = null; if (Build.VERSION.SDK_INT >= 16) { notification = new Notification.InboxStyle( new Notification.Builder(this).setContentTitle("A batch of Traps has been sent") .setContentText("\"Batched traps are waiting to be downloaded") .setSmallIcon(R.drawable.ic_stat_ratelimit).setVibrate(new long[] { 0, 100, 200, 300 }) .setAutoCancel(true).setSound(uri).setPriority(Notification.PRIORITY_HIGH) .setTicker("A batch of Traps has been sent") .addAction(R.drawable.ic_download_batch, "Get Batched Traps", pBroadcastDownload) .addAction(R.drawable.ic_ignore, "Ignore Batch", pBroadcastIgnore)) .setBigContentTitle("A batch of Traps has been sent") .setSummaryText("Launch ColdStart.io to Manage These Events") .addLine("A number of traps have been sent and batched for delivery") .addLine("The current number of items queued is " + batchCount).addLine(" ") .addLine("Tap \"Get Batched Traps\" to download the cached traps") .addLine("Tap \"Ignore Batch\" to delete them from the server.") .build(); } else {// www . j a v a2s. co m notification = new Notification.Builder(this).setContentTitle("A batch of Traps has been sent") .setContentText( "A number of traps have been sent and batched for delivery. The current number of items queued is " + batchCount + "\nTap \"Get Alerts\" to batch download the outstanding traps or tap \"Ignore\" to delete them from the server.") .setSmallIcon(R.drawable.ic_stat_ratelimit).setContentIntent(pIntent) .setVibrate(new long[] { 0, 100, 200, 300 }).setAutoCancel(true).setSound(uri).build(); } NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(43524, notification); }
From source file:net.kourlas.voipms_sms.Notifications.java
public void showNotifications(List<String> contacts) { if (!(ActivityMonitor.getInstance().getCurrentActivity() instanceof ConversationsActivity)) { Conversation[] conversations = Database.getInstance(applicationContext) .getConversations(preferences.getDid()); for (Conversation conversation : conversations) { if (!conversation.isUnread() || !contacts.contains(conversation.getContact()) || (ActivityMonitor.getInstance().getCurrentActivity() instanceof ConversationActivity && ((ConversationActivity) ActivityMonitor.getInstance().getCurrentActivity()) .getContact().equals(conversation.getContact()))) { continue; }/*from w w w.j av a 2 s . co m*/ String smsContact = Utils.getContactName(applicationContext, conversation.getContact()); if (smsContact == null) { smsContact = Utils.getFormattedPhoneNumber(conversation.getContact()); } String allSmses = ""; String mostRecentSms = ""; boolean initial = true; for (Message message : conversation.getMessages()) { if (message.getType() == Message.Type.INCOMING && message.isUnread()) { if (initial) { allSmses = message.getText(); mostRecentSms = message.getText(); initial = false; } else { allSmses = message.getText() + "\n" + allSmses; } } else { break; } } NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(applicationContext); notificationBuilder.setContentTitle(smsContact); notificationBuilder.setContentText(mostRecentSms); notificationBuilder.setSmallIcon(R.drawable.ic_chat_white_24dp); notificationBuilder.setPriority(Notification.PRIORITY_HIGH); notificationBuilder .setSound(Uri.parse(Preferences.getInstance(applicationContext).getNotificationSound())); notificationBuilder.setLights(0xFFAA0000, 1000, 5000); if (Preferences.getInstance(applicationContext).getNotificationVibrateEnabled()) { notificationBuilder.setVibrate(new long[] { 0, 250, 250, 250 }); } else { notificationBuilder.setVibrate(new long[] { 0 }); } notificationBuilder.setColor(0xFFAA0000); notificationBuilder.setAutoCancel(true); notificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(allSmses)); Bitmap largeIconBitmap; try { largeIconBitmap = MediaStore.Images.Media.getBitmap(applicationContext.getContentResolver(), Uri.parse(Utils.getContactPhotoUri(applicationContext, conversation.getContact()))); largeIconBitmap = Bitmap.createScaledBitmap(largeIconBitmap, 256, 256, false); largeIconBitmap = Utils.applyCircularMask(largeIconBitmap); notificationBuilder.setLargeIcon(largeIconBitmap); } catch (Exception ignored) { } Intent intent = new Intent(applicationContext, ConversationActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(applicationContext.getString(R.string.conversation_extra_contact), conversation.getContact()); TaskStackBuilder stackBuilder = TaskStackBuilder.create(applicationContext); stackBuilder.addParentStack(ConversationActivity.class); stackBuilder.addNextIntent(intent); notificationBuilder .setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT)); Intent replyIntent = new Intent(applicationContext, ConversationQuickReplyActivity.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { replyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } else { //noinspection deprecation replyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } replyIntent.putExtra(applicationContext.getString(R.string.conversation_extra_contact), conversation.getContact()); PendingIntent replyPendingIntent = PendingIntent.getActivity(applicationContext, 0, replyIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Action.Builder replyAction = new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_24dp, applicationContext.getString(R.string.notifications_button_reply), replyPendingIntent); notificationBuilder.addAction(replyAction.build()); Intent markAsReadIntent = new Intent(applicationContext, MarkAsReadReceiver.class); markAsReadIntent.putExtra(applicationContext.getString(R.string.conversation_extra_contact), conversation.getContact()); PendingIntent markAsReadPendingIntent = PendingIntent.getBroadcast(applicationContext, 0, markAsReadIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Action.Builder markAsReadAction = new NotificationCompat.Action.Builder( R.drawable.ic_drafts_white_24dp, applicationContext.getString(R.string.notifications_button_mark_read), markAsReadPendingIntent); notificationBuilder.addAction(markAsReadAction.build()); int id; if (notificationIds.get(conversation.getContact()) != null) { id = notificationIds.get(conversation.getContact()); } else { id = notificationIdCount++; notificationIds.put(conversation.getContact(), id); } NotificationManager notificationManager = (NotificationManager) applicationContext .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(id, notificationBuilder.build()); } } }
From source file:io.coldstart.android.GCMIntentService.java
private void sendRateLimitNotification(String rateLimitCount) { if (null == rateLimitCount) rateLimitCount = "0"; Intent intent = new Intent(this, TrapListActivity.class); intent.putExtra("forceDownload", true); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); Intent broadcastDownload = new Intent(); broadcastDownload.setAction(BatchDownloadReceiver.BROADCAST_ACTION); PendingIntent pBroadcastDownload = PendingIntent.getBroadcast(this, 0, broadcastDownload, 0); Intent broadcastIgnore = new Intent(); broadcastIgnore.setAction(BatchIgnoreReceiver.BROADCAST_ACTION); PendingIntent pBroadcastIgnore = PendingIntent.getBroadcast(this, 0, broadcastIgnore, 0); Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Notification notification = null; if (Build.VERSION.SDK_INT >= 16) { notification = new Notification.InboxStyle(new Notification.Builder(this) .setContentTitle("Inbound Traps have been rate limited") .setContentText(//w w w .j a va 2 s . c om "\"The number of traps being relayed to your phone has breeched the rate limit.") .setSmallIcon(R.drawable.ic_stat_ratelimit).setVibrate(new long[] { 0, 100, 200, 300 }) .setAutoCancel(true).setSound(uri).setPriority(Notification.PRIORITY_HIGH) .setTicker("Inbound Traps have been rate limited") .addAction(R.drawable.ic_download_batch, "Get Batched Traps", pBroadcastDownload) .addAction(R.drawable.ic_ignore, "Ignore Batch", pBroadcastIgnore)) .setBigContentTitle("Inbound Traps have been rate limited") .setSummaryText("Launch ColdStart.io to Manage These Events") .addLine("The number of traps relayed to you has breeched the rate limit.") .addLine("The current number of items queued is " + rateLimitCount).addLine(" ") .addLine("Tap \"Get Batched Traps\" to download the cached traps") .addLine("Tap \"Ignore Batch\" to delete them from the server.") .build(); } else { notification = new Notification.Builder(this).setContentTitle("Inbound Traps have been rate limited") .setContentText( "The number of traps being relayed to your phone has breeched the rate limit. The current number of items queued is " + rateLimitCount + "\nTap \"Get Alerts\" to batch download the outstanding traps or tap \"Ignore\" to delete them from the server.") .setSmallIcon(R.drawable.ic_stat_ratelimit).setContentIntent(pIntent) .setVibrate(new long[] { 0, 100, 200, 300 }).setAutoCancel(true).setSound(uri).build(); } NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(43524, notification); }
From source file:butter.droid.base.torrent.TorrentService.java
public void startForeground() { if (Foreground.get().isForeground()) return;/*from w ww. j a v a 2 s . c o m*/ if (mCurrentActivityClass == null) return; Intent notificationIntent = new Intent(this, mCurrentActivityClass); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); Intent stopIntent = new Intent(); stopIntent.setAction(TorrentBroadcastReceiver.STOP); PendingIntent pendingStopIntent = PendingIntent.getBroadcast(this, TorrentBroadcastReceiver.REQUEST_CODE, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action stopAction = new NotificationCompat.Action.Builder( R.drawable.abc_ic_clear_mtrl_alpha, getString(R.string.stop), pendingStopIntent).build(); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notif_logo) .setContentTitle(getString(R.string.app_name) + " - " + getString(R.string.running)) .setContentText(getString(R.string.tap_to_resume)).setOngoing(true).setOnlyAlertOnce(true) .setPriority(Notification.PRIORITY_LOW).setContentIntent(pendingIntent).addAction(stopAction) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (mStreamStatus != null && mIsReady) { String downloadSpeed; DecimalFormat df = new DecimalFormat("#############0.00"); if (mStreamStatus.downloadSpeed / 1024 < 1000) { downloadSpeed = df.format(mStreamStatus.downloadSpeed / 1024) + " KB/s"; } else { downloadSpeed = df.format(mStreamStatus.downloadSpeed / (1024 * 1024)) + " MB/s"; } String progress = df.format(mStreamStatus.progress); builder.setContentText(progress + "%, " + downloadSpeed); } Notification notification = builder.build(); NotificationManager notifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifManager.notify(NOTIFICATION_ID, notification); startForeground(NOTIFICATION_ID, notification); if (mUpdateTimer == null) { mUpdateTimer = new Timer(); mUpdateTimer.scheduleAtFixedRate(new UpdateTask(), 5000, 5000); } }
From source file:com.footprint.cordova.plugin.localnotification.Receiver.java
/** * Shows the notification/*from ww w .j a va 2 s.co m*/ */ @SuppressWarnings("deprecation") private void showNotification(Builder notification) { NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); int id = 0; try { id = Integer.parseInt(options.getId()); } catch (Exception e) { } if (Build.VERSION.SDK_INT < 16) { // build notification for HoneyComb to ICS mgr.notify(id, notification.getNotification()); } else if (Build.VERSION.SDK_INT > 15) { // Notification for Jellybean and above mgr.notify(id, notification.build()); } }
From source file:am.roadpolice.roadpolice.alarm.AlarmReceiver.java
@Override public void submissionCompleted(ArrayList<ViolationInfo> list, String result) { // If errors occurs while trying to update data. if (!TextUtils.isEmpty(result)) { final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor ed = sp.edit(); ed.putBoolean(MainActivity.MISS_UPDATE_DUE_TO_NETWORK_ISSUE, true); ed.apply();/*from w ww. j a va 2 s . co m*/ return; } SQLiteHelper dbHelper = new SQLiteHelper(mContext); // Get list of new violation info, if null no new items found. ArrayList<ViolationInfo> newViolationInfoList = dbHelper.insertViolationInfoListAndCheckNew(list); // Create notification. NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext); // Create notification Title Text. int updateInterval = DialogSettings.getUpdateInterval(mContext); switch (updateInterval) { case DialogSettings.DAILY: mBuilder.setContentTitle(mContext.getString(R.string.txtDailyNotification)); break; case DialogSettings.WEEKLY: mBuilder.setContentTitle(mContext.getString(R.string.txtWeeklyNotification)); break; case DialogSettings.MONTHLY: mBuilder.setContentTitle(mContext.getString(R.string.txtMonthlyNotification)); break; } // Create notification message. if (newViolationInfoList == null || newViolationInfoList.size() < 1) { mBuilder.setContentText(mContext.getString(R.string.txtNoViolationNotification)); mBuilder.setSmallIcon(R.drawable.ic_checked); } else { mBuilder.setContentText(mContext.getString(R.string.txtYesViolationNotification)); mBuilder.setSmallIcon(R.drawable.ic_attention); } // Activate vibration and sound. mBuilder.setDefaults(Notification.DEFAULT_SOUND); mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); mBuilder.setAutoCancel(true); // Set intent to open Main Activity, when user click on notification. Intent notificationIntent = new Intent(mContext, MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent mainActivityPendingIntent = PendingIntent.getActivity(mContext, 0, notificationIntent, 0); mBuilder.setContentIntent(mainActivityPendingIntent); // Show notification. NotificationManager mNotificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(0, mBuilder.build()); // Get shared preferences. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor ed = sp.edit(); ed.putBoolean(MainActivity.MISS_UPDATE_DUE_TO_NETWORK_ISSUE, false); ed.apply(); }
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. j av a 2 s . c o m*/ } 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); }