@@ -24,51 +24,54 @@ public class RangingActivity extends Activity implements BeaconConsumer {
2424    @ Override 
2525    protected  void  onCreate (Bundle  savedInstanceState ) {
2626        super .onCreate (savedInstanceState );
27- 		 setContentView (R .layout .activity_ranging );
27+          setContentView (R .layout .activity_ranging );
2828
2929        beaconManager .bind (this );
3030    }
31+ 
3132    @ Override  
3233    protected  void  onDestroy () {
3334        super .onDestroy ();
3435        beaconManager .unbind (this );
3536    }
37+ 
3638    @ Override  
3739    protected  void  onPause () {
38-     	 super .onPause ();
39-     	 if  (beaconManager .isBound (this )) beaconManager .setBackgroundMode (true );
40+          super .onPause ();
41+          if  (beaconManager .isBound (this )) beaconManager .setBackgroundMode (true );
4042    }
43+ 
4144    @ Override  
4245    protected  void  onResume () {
43-     	 super .onResume ();
44-     	 if  (beaconManager .isBound (this )) beaconManager .setBackgroundMode (false );
46+          super .onResume ();
47+          if  (beaconManager .isBound (this )) beaconManager .setBackgroundMode (false );
4548    }
4649
4750    @ Override 
4851    public  void  onBeaconServiceConnect () {
4952        beaconManager .setRangeNotifier (new  RangeNotifier () {
50-         @ Override   
51-         public  void  didRangeBeaconsInRegion (Collection <Beacon > beacons , Region  region ) {
52-             if  (beacons .size () > 0 ) {
53-             	 EditText  editText  = (EditText )RangingActivity .this 
54- 						. findViewById ( R . id . rangingText );
55-                 Beacon   firstBeacon  =  beacons . iterator (). next ( );
56-                  logToDisplay ( "The first beacon " + firstBeacon . toString ()+ " is about " + firstBeacon . getDistance ()+ " meters away." );             }
57-         }
53+             @ Override 
54+             public  void  didRangeBeaconsInRegion (Collection <Beacon > beacons , Region  region ) {
55+                if  (beacons .size () > 0 ) {
56+                   // EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText); 
57+                   Beacon   firstBeacon  =  beacons . iterator (). next ( );
58+                   logToDisplay ( "The first beacon "  +  firstBeacon . toString () +  " is about "  +  firstBeacon . getDistance () +  " meters away." );
59+               }
60+             }
5861
5962        });
6063
6164        try  {
6265            beaconManager .startRangingBeaconsInRegion (new  Region ("myRangingUniqueId" , null , null , null ));
6366        } catch  (RemoteException  e ) {   }
6467    }
68+ 
6569    private  void  logToDisplay (final  String  line ) {
66-     	runOnUiThread (new  Runnable () {
67-     	    public  void  run () {
68-     	    	EditText  editText  = (EditText )RangingActivity .this 
69-     					.findViewById (R .id .rangingText );
70-     	    	editText .append (line +"\n " );            	
71-     	    }
72-     	});
70+         runOnUiThread (new  Runnable () {
71+             public  void  run () {
72+                 EditText  editText  = (EditText )RangingActivity .this .findViewById (R .id .rangingText );
73+                 editText .append (line +"\n " );
74+             }
75+         });
7376    }
7477}
0 commit comments