Ejemplo n.º 1
0
    @Override
    public void onExit(Place place, long time, long duration) {
      //			Activity activity = BackgroundGeofencingPlugin.this.cordova.getActivity();
      //			NotificationManager mNotificationManager = (NotificationManager)
      // activity.getSystemService(Context.NOTIFICATION_SERVICE);
      //
      //			Intent main = new Intent(activity, CordovaApp.class);
      //            main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      //
      //            PendingIntent pendingIntent = PendingIntent.getActivity(activity, 0, main,
      // PendingIntent.FLAG_UPDATE_CURRENT);
      //            Notification.Builder builder = new Notification.Builder(activity);
      //            builder.setContentTitle("farewell:"+place.getPlaceName());
      //            builder.setContentText("exit:" + place.getPlaceName());
      //            builder.setSmallIcon(android.R.drawable.ic_menu_mylocation);
      //            builder.setContentIntent(pendingIntent);
      //            builder.setAutoCancel(true);
      //
      //            mNotificationManager.notify((int) System.currentTimeMillis(), builder.build());

      Toast.makeText(activity, "exit place:" + place.getPlaceName(), Toast.LENGTH_LONG);

      Log.v(
          Config.TAG,
          "exit place :" + place.getPlaceName() + "	at time:" + time + "	for:" + duration);
    }
Ejemplo n.º 2
0
    @Override
    public void onEnter(Place place, long time) {
      //			Activity activity = BackgroundGeofencingPlugin.this.cordova.getActivity();
      NotificationManager mNotificationManager =
          (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
      JSONObject offerData = new JSONObject();
      try {
        offerData.put("offerUuid", place.getOfferUuid());
        offerData.put("placeName", place.getPlaceName());
      } catch (JSONException e) {
        e.printStackTrace();
      }

      Intent intent = new Intent(activity, CordovaApp.class);
      //			intent.addCategory(INTENT_CATEGORY_OFFER_NOTIFICATION);
      Uri.Builder uriBuilder = new Uri.Builder();
      uriBuilder.scheme(INTENT_DATA_SCHEME_OFFER_NOTIFICATION);
      uriBuilder.authority(INTENT_HOST_OFFER_NOTIFICATION);
      uriBuilder.appendQueryParameter("placeUuid", place.getUuid());
      intent.setData(uriBuilder.build());
      intent.putExtra(INTENT_EXTRA_KEY_NOTIFICATION_OFFER_DATA, offerData.toString());
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

      PendingIntent pendingIntent =
          PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

      Notification.Builder builder = new Notification.Builder(activity);
      // builder.setContentTitle(place.getPlaceName()+" has a new offer"); //By Abdullah
      builder.setContentTitle(place.getPlaceName()); // By Abdullah
      // builder.setContentText("Click here to view the offer");		//By Abdullah
      builder.setContentText(place.getShortDesc()); // By Abdullah
      builder.setSmallIcon(R.drawable.icon);
      builder.setContentIntent(pendingIntent);
      builder.setAutoCancel(true);
      builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

      mNotificationManager.notify((int) System.currentTimeMillis(), builder.build());

      Log.v(Config.TAG, "enter into place :" + place.getPlaceName() + "	at time:" + time);

      // unregister place in apigee
      Intent tripPlanSyncIntent = new Intent(activity, TripPlanSyncService.class);
      tripPlanSyncIntent.putExtra(TripPlanSyncService.PLACE_ID_TO_UNSUBSRIBE, place.getUuid());
      activity.startService(tripPlanSyncIntent);
    }
Ejemplo n.º 3
0
 private void unregisterPlace(Place place) {
   Intent intent = new Intent(INTENT_ACTION_GEOTRIGGER_STATIONARY_PROXIMITY_ALERT);
   intent.addCategory(INTENT_CATEGORY_GEOTRIGGER);
   PendingIntent pendingIntent = getPendingIntentByPlace(context, place, intent, false);
   if (pendingIntent != null) {
     this.locationManager.removeProximityAlert(pendingIntent);
     Log.v(Config.TAG, place.getPlaceName() + " removed");
   }
 }