title: Unable to display notification when entering GeoFence in Android
body: <p>I am working on <code>GeoFencing</code> in Android and I am stuck at one point. My task is to show <code>notification</code> to user when he enters/exits a <code>Geofence</code> area defined by me.</p>
  
  <p>Here is my code:</p>
  
  <p><code>Activity class</code></p>
  
  <pre><code>public class TestMapActivity extends FragmentActivity implements    
      OnMarkerDragListener,ConnectionCallbacks, OnConnectionFailedListener,OnAddGeofencesResultListener {
  
  private static GoogleMap map;
  private LocationClient mLocationClient;
  private PendingIntent mGeofencePendingIntent;
  private SimpleGeoFence fence;
  private List&lt;Geofence&gt; mGeoList;
  private LocationRequest localRequest;
  private GeofenceReceiver mBroadcastReceiver;
  private IntentFilter mIntentFilter;
  
  @Override
  protected void onCreate(Bundle saveInstance)
  {
          super.onCreate(saveInstance);
          setContentView(R.layout.activity_map);
          map = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
          map.setOnMarkerDragListener(this);
          CameraPosition INIT =
          new CameraPosition.Builder()
          .target(new LatLng(19.0222, 72.8666))
          .zoom(17.5F)
          .bearing(300F) // orientation
          .tilt( 50F) // viewing angle
          .build();
           map.moveCamera( CameraUpdateFactory.newCameraPosition(INIT) );
  
   }
  
  
     @Override
      public boolean onCreateOptionsMenu(Menu menu)
      {
          MenuInflater menuInflater = getMenuInflater();
          menuInflater.inflate(R.menu.main, menu);
          return true;
      }
  
   @Override
      public boolean onOptionsItemSelected(MenuItem item)
      {
  
          switch (item.getItemId())
          {
              case R.id.add_fence:
  
              Toast.makeText(TestMapActivity.this, "Add fence is Selected", Toast.LENGTH_LONG).show();
  
              fence= new SimpleGeoFence();
              fence.toGeofence();
              addMarkerForFence(fence);
              addIntentForFence();
              return true;
              default:
                   return super.onOptionsItemSelected(item);
          }
      }
  
       public void addMarkerForFence(SimpleGeoFence fence){
       if(fence == null){
           // display an error message and return
          return;
       }
  
  
       //Instantiates a new CircleOptions object +  center/radius
       CircleOptions circleOptions = new CircleOptions()
         .center( new LatLng(19.0216, 72.8646 ))
         .radius( 500 )
         .fillColor(0x40ff0000)
         .strokeColor(Color.TRANSPARENT)
         .strokeWidth(2);
  
       map.addCircle(circleOptions);
  
       map.addMarker( new MarkerOptions()
         .position( new LatLng(19.0216, 72.8646) )
         .title("Fence " +fence.getId())
         .snippet("Radius: " +fence.getRadius()) ).showInfoWindow();
  
       // Get back the mutable Circle
       Circle circle = map.addCircle(circleOptions);
  
   }
  
       public void addIntentForFence()
   {
  
       Geofence geoFence= fence.toGeofence();
       mGeoList = new ArrayList&lt;Geofence&gt;();
       mGeoList.add(geoFence);
  
       mLocationClient = new LocationClient(this, this, this);
       mLocationClient.connect();
  
      }
  
     @Override
  public void onConnected(Bundle arg0) {
      // TODO Auto-generated method stub
  
      mGeofencePendingIntent = createRequestPendingIntent(); 
  
      localRequest = LocationRequest.create();
      localRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
      localRequest.setInterval(5000);
  
      mLocationClient.addGeofences(mGeoList, mGeofencePendingIntent , this);  
  }
  
      private PendingIntent createRequestPendingIntent() {
  
      if (null != mGeofencePendingIntent) {
  
          return mGeofencePendingIntent;
  
      } else {
  
  
          Intent intent = new Intent("com.example.ACTION_RECEIVE_GEOFENCE");
          System.out.println("Intent" +intent);
          //sendBroadcast(intent);
          return PendingIntent.getBroadcast(
                  getApplicationContext(),
                  0,
                  intent,
                  PendingIntent.FLAG_UPDATE_CURRENT);
      }
  }
  } //end oncreate
  </code></pre>
  
  <p><code>GeofenceReceiver class</code></p>
  
  <pre><code>  public class GeofenceReceiver extends BroadcastReceiver
    {
           public Context context;
           Intent broadcastIntent = new Intent();
  
            @Override
        public void onReceive(Context context, Intent intent) {
  
             // TODO Auto-generated method stub
  
               this.context = context;
                broadcastIntent.addCategory("com.example.CATEGORY_LOCATION_SERVICES");        
                String action= intent.getAction();
  
                 if (LocationClient.hasError(intent)) {
                         //do something
                  } 
                 else 
                  {
                 handleEnterExit(intent);
                   }
             }
  
           private void handleEnterExit(Intent intent) {
  
               int transition = LocationClient.getGeofenceTransition(intent);
  
                System.out.println("transition" +transition); //getting -1 over here
                if ((transition == Geofence.GEOFENCE_TRANSITION_ENTER)
                  || (transition == Geofence.GEOFENCE_TRANSITION_EXIT)) {
  
                           //send notification over here
               }   
  
      } 
  </code></pre>
  
  <p><code>AndroidManifest.xml</code> container Receiver </p>
  
  <pre><code>    &lt;receiver android:name="com.example.GeofenceReceiver" android:exported="false"&gt;
      &lt;intent-filter &gt;
          &lt;action android:name="com.example.ACTION_RECEIVE_GEOFENCE"/&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>So basically I am able to see my GeoFence getting created but i don't get notification for the same.</p>
  
  <p>does anyone have a solution for this?</p>