我在我的應用程序中使用地理柵欄,除了刪除觸發的地理柵欄之外,一切正常。 我從Android的官方文檔中獲取紅色指南,但他們沒有解釋如何去除IntentService中的地理圍欄。觸發後刪除地理柵欄
這裏是服務的事件處理程序的代碼:
@Override
protected void onHandleIntent(Intent intent)
{
Log.e("GeofenceIntentService", "Location handled");
if (LocationClient.hasError(intent))
{
int errorCode = LocationClient.getErrorCode(intent);
Log.e("GeofenceIntentService", "Location Services error: " + Integer.toString(errorCode));
}
else
{
int transitionType = LocationClient.getGeofenceTransition(intent);
if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER)
{
List <Geofence> triggerList = LocationClient.getTriggeringGeofences(intent);
String[] triggerIds = new String[triggerList.size()];
for (int i = 0; i < triggerIds.length; i++)
{
// Store the Id of each geofence
triggerIds[i] = triggerList.get(i).getRequestId();
Picture p = PicturesManager.getById(triggerIds[i], getApplicationContext());
/* ... do a lot of work here ... */
}
}
else
Log.e("ReceiveTransitionsIntentService", "Geofence transition error: " + Integer.toString(transitionType));
}
}
如何刪除地理圍欄他得到觸發後?
所以我創建的服務LocationClient? – Gp2mv3
我不知道,添加Geofences時,你在哪裏創建它? – Jeshurun
LocationClient不再包含在播放服務中。 – mrroboaat