Я использую ActivityRecognitionClient, чтобы получить переход активности, следуя this
, но результат всегда равен нулю при успехе.
public void requestActivityTransitionUpdate(final Context context){
ActivityTransitionRequest activityTransitionRequest = buildActivityTransitionRequest();
Intent tempIntent = new Intent(this, ReceiverActivityTransition.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, tempIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Task task = ActivityRecognition.getClient(context).requestActivityTransitionUpdates(activityTransitionRequest, pendingIntent);
task.addOnSuccessListener(
new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void result) {
Log.i("Success","LocationUpdatesService");
}
}
);
task.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(Exception e) {
// Handle error
Log.i("Success","LocationUpdatesService");
}
}
);
}