10
10
import android .os .Bundle ;
11
11
import android .support .v4 .content .LocalBroadcastManager ;
12
12
import android .widget .CompoundButton ;
13
- import android .widget .Toast ;
14
13
import android .widget .ToggleButton ;
15
14
16
15
import com .google .android .gms .common .ConnectionResult ;
@@ -72,38 +71,27 @@ private void verifyPlayServices() {
72
71
break ;
73
72
}
74
73
case ConnectionResult .SERVICE_VERSION_UPDATE_REQUIRED : {
75
- Toast .makeText ( this ,
76
- "Geofencing service requires an update, please open Google Play." ,
77
- Toast .LENGTH_SHORT ).show ();
78
74
finish ();
79
75
}
80
76
default : {
81
- Toast .makeText (this ,
82
- "Geofencing service is not available." ,
83
- Toast .LENGTH_SHORT ).show ();
84
77
finish ();
85
78
}
86
79
}
87
80
}
88
81
89
82
private void startGeofence () {
90
- Toast .makeText ( this , "startGeofence" , Toast .LENGTH_SHORT ).show ();
91
83
Location location = mLocationClient .getLastLocation ();
92
84
int radius = 100 ;
93
85
94
86
Geofence .Builder builder = new Geofence .Builder ();
95
87
mGeofence = builder
96
- //Unique to this geofence
97
88
.setRequestId (FENCE_ID )
98
- //Size and location
99
89
.setCircularRegion (
100
90
location .getLatitude (),
101
91
location .getLongitude (),
102
92
radius )
103
- //Events both in and out of the fence
104
93
.setTransitionTypes (Geofence .GEOFENCE_TRANSITION_ENTER
105
94
| Geofence .GEOFENCE_TRANSITION_EXIT )
106
- //Keep alive
107
95
.setExpirationDuration (Geofence .NEVER_EXPIRE )
108
96
.build ();
109
97
@@ -132,14 +120,8 @@ protected void onPause() {
132
120
}
133
121
134
122
public class GeofenceSampleReceiver extends BroadcastReceiver {
135
- /*
136
- * Define the required method for broadcast receivers
137
- * This method is invoked when a broadcast Intent triggers the receiver
138
- */
139
123
@ Override
140
124
public void onReceive (Context context , Intent intent ) {
141
-
142
- Toast .makeText ( context , "onReceive: " + intent .getAction ().toString () , Toast .LENGTH_SHORT ).show ();
143
125
startService ( mIntent );
144
126
}
145
127
}
@@ -156,9 +138,7 @@ public void onDisconnected() {
156
138
157
139
@ Override
158
140
public void onAddGeofencesResult (int status , String [] geofenceIds ) {
159
- Toast .makeText ( this , "addGeofencesResult" , Toast .LENGTH_SHORT ).show ();
160
141
if ( status == LocationStatusCodes .SUCCESS ) {
161
- Toast .makeText ( this , "addGseofencesResult SUCCESS" , Toast .LENGTH_SHORT ).show ();
162
142
Intent intent = new Intent ( mIntent );
163
143
intent .setAction (GeofencingService .ACTION_INIT );
164
144
startService ( intent );
@@ -181,7 +161,6 @@ public void onRemoveGeofencesByRequestIdsResult(int status, String[] strings) {
181
161
@ Override
182
162
public void onRemoveGeofencesByPendingIntentResult (int status , PendingIntent pendingIntent ) {
183
163
if ( status == LocationStatusCodes .SUCCESS ) {
184
- Toast .makeText ( this , "onRemoveGeofencesByPendingIntentResult SUCCESS" , Toast .LENGTH_SHORT ).show ();
185
164
stopService ( mIntent );
186
165
}
187
166
}
0 commit comments