com.google.android.gms.common.ConnectionResult Java Examples

The following examples show how to use com.google.android.gms.common.ConnectionResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_where_am_i);

  mTextView = findViewById(R.id.myLocationText);

  GoogleApiAvailability availability = GoogleApiAvailability.getInstance();

  int result = availability.isGooglePlayServicesAvailable(this);
  if (result != ConnectionResult.SUCCESS) {
    if (!availability.isUserResolvableError(result)) {
      Toast.makeText(this, ERROR_MSG, Toast.LENGTH_LONG).show();
    }
  }
}
 
Example #2
Source File: BaseCastManager.java    From UTubeTV with The Unlicense 6 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult result) {
  CastUtils.LOGD(TAG, "onConnectionFailed() reached, error code: " + result.getErrorCode() + ", reason: " + result
      .toString());
  mSelectedCastDevice = null;
  if (null != mMediaRouter) {
    mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
  }
  boolean showError = false;
  if (null != mBaseCastConsumers) {
    for (IBaseCastConsumer consumer : mBaseCastConsumers) {
      try {
        consumer.onConnectionFailed(result);
      } catch (Exception e) {
        CastUtils.LOGE(TAG, "onConnectionFailed(): Failed to inform " + consumer, e);
      }
    }
  }
  if (showError) {
    CastUtils.showErrorDialog(mContext, R.string.failed_to_connect);
  }
}
 
Example #3
Source File: MainActivity.java    From gplus-haiku-client-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    Log.d(TAG, "Connection failed");

    if (mIsResolving) {
        Log.d(TAG, "Already resolving.");
        return;
    }

    // Attempt to resolve the ConnectionResult
    if (connectionResult.hasResolution() && mSignInClicked) {
        mIsResolving = true;
        mSignInClicked = false;

        try {
            connectionResult.startResolutionForResult(this, REQ_SIGN_IN);
        } catch (IntentSender.SendIntentException e) {
            Log.e(TAG, "Could not resolve.", e);
            mIsResolving = false;
            mGoogleApiClient.connect();
        }
    }
}
 
Example #4
Source File: DataCastManager.java    From android with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the DataCastManager for clients. Before clients can use DataCastManager, they
 * need to initialize it by calling this static method. Then clients can obtain an instance of
 * this singleton class by calling {@link DataCastManager#getInstance()}. Failing to initialize
 * this class before requesting an instance will result in a {@link CastException} exception.
 *
 * @param context
 * @param applicationId the unique ID for your application
 * @param namespaces to be set up for this class.
 * @return
 */
public static DataCastManager initialize(Context context,
        String applicationId, String... namespaces) {
    if (null == sInstance) {
        LOGD(TAG, "New instance of DataCastManager is created");
        if (ConnectionResult.SUCCESS != GooglePlayServicesUtil
                .isGooglePlayServicesAvailable(context)) {
            String msg = "Couldn't find the appropriate version of Google Play Services";
            LOGE(TAG, msg);
            throw new RuntimeException(msg);
        }
        sInstance = new DataCastManager(context, applicationId, namespaces);
        mCastManager = sInstance;
    }
    return sInstance;
}
 
Example #5
Source File: OpenLocate.java    From openlocate-android with MIT License 6 votes vote down vote up
public static OpenLocate initialize(Configuration configuration) {

        saveConfiguration(configuration);

        if (sharedInstance == null) {
            sharedInstance = new OpenLocate(configuration);
        }

        boolean trackingEnabled = SharedPreferenceUtils.getInstance(configuration.context).getBoolanValue(Constants.TRACKING_STATUS, false);

        if (trackingEnabled && hasLocationPermission(configuration.context) &&
                sharedInstance.isGooglePlayServicesAvailable() == ConnectionResult.SUCCESS) {
            sharedInstance.onPermissionsGranted();
        }

        return sharedInstance;
    }
 
Example #6
Source File: GcmAvailableHelper.java    From android-job with Apache License 2.0 6 votes vote down vote up
public static boolean isGcmApiSupported(Context context) {
    try {
        if (!checkedServiceEnabled) {
            checkedServiceEnabled = true;
            setServiceEnabled(context, GCM_IN_CLASSPATH);
        }

        return GCM_IN_CLASSPATH
                && GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS
                && isGcmServiceRegistered(context) == ConnectionResult.SUCCESS;
    } catch (Throwable t) {
        // seeing sometimes a DeadObjectException, return false, we can't do anything in this case
        // still sometimes seeing a NoClassDefFoundError here
        if (BuildConfig.DEBUG) {
            CAT.w(t.getMessage());
        }
        return false;
    }
}
 
Example #7
Source File: ConnectionActivity.java    From Android-GSDemo-GoogleMap with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {

        case R.id.btn_open: {
            int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
            if(status != ConnectionResult.SUCCESS) {
                GooglePlayServicesUtil.getErrorDialog(status, this, status);
                showToast("Cannot run without Google Play, please check!");
            } else {
                Intent intent = new Intent(this, MainActivity.class);
                startActivity(intent);
            }
            break;
        }
        default:
            break;
    }
}
 
Example #8
Source File: BarcodeCaptureActivity.java    From android-vision with Apache License 2.0 6 votes vote down vote up
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() throws SecurityException {
    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
Example #9
Source File: MapsActivity.java    From vocefiscal-android with Apache License 2.0 6 votes vote down vote up
/**
 * Check the device to make sure it has the Google Play Services APK. If
 * it doesn't, display a dialog that allows users to download the APK from
 * the Google Play Store or enable it in the device's system settings.
 */
private boolean checkPlayServices() 
{
	int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
	if (resultCode != ConnectionResult.SUCCESS) 
	{
		if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) 
		{
			GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
		} else 
		{
			finish();
		}
		return false;
	}
	return true;
}
 
Example #10
Source File: PermissionCheckGooglePlayServices.java    From magnet-client with Mozilla Public License 2.0 6 votes vote down vote up
public void check() {
    final GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    final int result = googleApiAvailability.isGooglePlayServicesAvailable(getActivity());

    if (result == ConnectionResult.SUCCESS) {
        done();
        return;
    }

    // IMPORTANT: We can't be sure that this code is
    // running on main-ui-thread, it depends where the
    // method was called from. For example React Native
    // responds to native bridge methods off main-ui-thread.
    // If a dialog is dispatched from a non-ui-thread thread,
    // when it is dismissed on main-ui-thread the app will crash.
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            googleApiAvailability.showErrorDialogFragment(getActivity(), result, ID);
            done();
        }
    });
}
 
Example #11
Source File: ExternalAuthUtils.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Same as {@link #canUseGooglePlayServices(Context, UserRecoverableErrorHandler)}.
 * @param context The current context.
 * @param errorHandler How to handle user-recoverable errors; must be non-null.
 * @return the result code specifying Google Play Services availability.
 */
public int canUseGooglePlayServicesResultCode(
        final Context context, final UserRecoverableErrorHandler errorHandler) {
    final int resultCode = checkGooglePlayServicesAvailable(context);
    recordConnectionResult(resultCode);
    if (resultCode != ConnectionResult.SUCCESS) {
        // resultCode is some kind of error.
        Log.v(TAG, "Unable to use Google Play Services: %s", describeError(resultCode));

        if (isUserRecoverableError(resultCode)) {
            Runnable errorHandlerTask = new Runnable() {
                @Override
                public void run() {
                    errorHandler.handleError(context, resultCode);
                }
            };
            ThreadUtils.runOnUiThread(errorHandlerTask);
        }
    }
    return resultCode;
}
 
Example #12
Source File: MainActivity.java    From AndroidWearable-Samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Disconnected from Google Api Service");
    }
    if (null != Wearable.NodeApi) {
        Wearable.NodeApi.removeListener(mGoogleApiClient, this);
    }
    if (mResolvingError) {
        // Already attempting to resolve an error.
        return;
    } else if (result.hasResolution()) {
        try {
            mResolvingError = true;
            result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
        } catch (IntentSender.SendIntentException e) {
            // There was an error with the resolution intent. Try again.
            mGoogleApiClient.connect();
        }
    } else {
        mResolvingError = false;
    }
}
 
Example #13
Source File: GoogleFitServiceCommandTest.java    From JayPS-AndroidApp with MIT License 6 votes vote down vote up
@SmallTest
public void testOnConnectionFailedPostsEvent() throws Exception {
    PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(),1, new Intent("MOCK"),0);
    ConnectionResult result = new ConnectionResult(0,pendingIntent);

    _command.execute(_app);
    _bus.post(new GoogleFitChangeState(BaseChangeState.State.START));
    _stateLatch.await(1000, TimeUnit.MILLISECONDS);

    _stateLatch = new CountDownLatch(1);
    _command.onConnectionFailed(result);

    _stateLatch.await(2000,TimeUnit.MILLISECONDS);

    assertEquals(BaseStatus.Status.UNABLE_TO_START, _state.getStatus());
}
 
Example #14
Source File: FaceFilterActivity.java    From FaceFilter with MIT License 6 votes vote down vote up
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() {

    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
Example #15
Source File: BackgroundService.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult arg0) {
	Debug.log("ActivityRecognitionClient connection failed");

	activityConnected = false;				
	signalStop();
}
 
Example #16
Source File: LoginActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(@NonNull ConnectionResult result) {
    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
        } catch (IntentSender.SendIntentException ignore) {
            // The intent was canceled before it was sent.
        }
    }
}
 
Example #17
Source File: BaseGooglePlayServicesActivity.java    From Onesearch with MIT License 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        return;
    }

    if (mSignInClicked || mAutoStartSignInflow) {
        mAutoStartSignInflow = false;
        mSignInClicked = false;

        mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.sign_in_failed));
    }
}
 
Example #18
Source File: DataManager.java    From GoogleFitExample with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult result) {
    Log.i(TAG, "Connection failed. Cause: " + result.toString());
    Context context = getContext();
    if (!result.hasResolution()) {
        // Show the localized error dialog
        if (context != null) {
            if (context instanceof Activity) {
                GoogleApiAvailability gApi = GoogleApiAvailability.getInstance();
                gApi.getErrorDialog((Activity) context, result.getErrorCode(), 0).show();
            }

        }
        return;
    }
    // The failure has a resolution. Resolve it.
    // Called typically when the app is not yet authorized, and an
    // authorization dialog is displayed to the user.
    if (!authInProgress) {
        try {
            Log.i(TAG, "Attempting to resolve failed connection");
            if (context != null) {
                if (context instanceof Activity) {
                    authInProgress = true;
                    result.startResolutionForResult((Activity) context,
                            REQUEST_OAUTH);
                }
            }
        } catch (IntentSender.SendIntentException e) {
            Log.e(TAG,
                    "Exception while starting resolution activity", e);
        }
    }
}
 
Example #19
Source File: MenuActivity.java    From FixMath with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mResolvingConnectionFailure) {
        // Already resolving
        return;
    }

    // If the sign in button was clicked or if auto sign-in is enabled,
    // launch the sign-in flow
    if (mSignInClicked || mAutoStartSignInFlow) {
        mAutoStartSignInFlow = false;
        mSignInClicked = false;
        mResolvingConnectionFailure = true;

        // Attempt to resolve the connection failure using BaseGameUtils.
        // The R.string.signin_other_error value should reference a generic
        // error string in your strings.xml file, such as "There was
        // an issue with sign in, please try again later."
        if (!BaseGameUtils.resolveConnectionFailure(this,
                mGoogleApiClient, connectionResult,
                RC_SIGN_IN, getString(R.string.signin_other_error))) {
            mResolvingConnectionFailure = false;
        }
    }


    googlePlayBtn.setVisibility(View.VISIBLE);

}
 
Example #20
Source File: FriendlyPingActivity.java    From friendlyping with Apache License 2.0 5 votes vote down vote up
private void showErrorDialog(ConnectionResult connectionResult) {
    final int errorCode = connectionResult.getErrorCode();
    if (GooglePlayServicesUtil.isUserRecoverableError(errorCode)) {
        // Show the default Google Play services error dialog which may still start an
        // intent on our behalf if the user can resolve the issue.
        GooglePlayServicesUtil.getErrorDialog(errorCode,
                FriendlyPingActivity.this, REQUEST_CODE_SIGN_IN,
                new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        mShouldResolve = false;
                        // For simplicity reasons we just finish the activity.
                        // In a real world app you should deal with failing properly.
                        Log.i(TAG, "Could not resolve issue with code: " + errorCode);
                        finish();
                    }
                }).show();
    } else {
        // No default Google Play Services error, display a Toast
        Toast.makeText(FriendlyPingActivity.this,
                getString(R.string.play_services_error_fmt, errorCode), Toast.LENGTH_SHORT)
                .show();
        mShouldResolve = false;
        // For simplicity reasons we just finish the activity.
        // In a real world app you should deal with failing properly.
        Log.i(TAG, "Could not resolve issue with code: " + errorCode);
        finish();
    }
}
 
Example #21
Source File: ChromeCastController.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
public void onConnectionFailed(final ConnectionResult result) {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "onConnectionFailed$result: " + result.toString());
    }
    teardown();
}
 
Example #22
Source File: AppLocationCompatActivity.java    From GooglePlayServiceLocationSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean servicesConnected() {
    // Check that Google Play services is available
    int resultCode = mGoogleApiAvailability.isGooglePlayServicesAvailable(this);

    // If Google Play services is available
    if (ConnectionResult.SUCCESS == resultCode) {
        if (mGoogleApiClient.isConnected())
            return true;
        else
            return false;
    }
    return false;
}
 
Example #23
Source File: WearService.java    From TutosAndroidFrance with MIT License 5 votes vote down vote up
/**
 * Appellé à la réception d'un message envoyé depuis la montre
 *
 * @param messageEvent message reçu
 */
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);

    //Ouvre une connexion vers la montre
    ConnectionResult connectionResult = mApiClient.blockingConnect(30, TimeUnit.SECONDS);

    if (!connectionResult.isSuccess()) {
        Log.e(TAG, "Failed to connect to GoogleApiClient.");
        return;
    }

    //traite le message reçu
    final String path = messageEvent.getPath();

    if (path.equals("bonjour")) {

        //Utilise Retrofit pour réaliser un appel REST
        AndroidService androidService = new RestAdapter.Builder()
                .setEndpoint(AndroidService.ENDPOINT)
                .build().create(AndroidService.class);

        //Récupère et deserialise le contenu de mon fichier JSON en objet Element
        androidService.getElements(new Callback<List<Element>>() {
            @Override
            public void success(List<Element> elements, Response response) {
                envoyerListElements(elements);
            }

            @Override
            public void failure(RetrofitError error) {
            }
        });

    }
}
 
Example #24
Source File: MainActivity.java    From jterm-cswithandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    // An unresolvable error has occurred and Google APIs (including Sign-In) will not
    // be available.
    Log.d(TAG, "onConnectionFailed:" + connectionResult);
    Toast.makeText(this, "Google Play Services error.", Toast.LENGTH_SHORT).show();
}
 
Example #25
Source File: LoginActivity.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
        } catch (IntentSender.SendIntentException e) {
            mPlusClient.connect();
        }
    }
    mConnectionResult = result;
}
 
Example #26
Source File: WelcomeActivitySign.java    From SimplicityBrowser with MIT License 5 votes vote down vote up
private boolean checkPlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            noPlayServices();
        } else {
            Cardbar.snackBar(this, "This device is not supported.", true).show();
        }
        return false;
    }
    return true;
}
 
Example #27
Source File: UtilityService.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sends current Wearable Settings made in Smartphone app over to the Wearable companion app
 */
private void sendSettingsToWearable() {
    Log.d("Sending Settings to Wearable...");
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API).build();

    // It's OK to use blockingConnect() here as we are running in an
    // IntentService that executes work on a separate (background) thread.
    ConnectionResult connectionResult = googleApiClient.blockingConnect(
            SettingsConstants.GOOGLE_API_CLIENT_TIMEOUT, TimeUnit.SECONDS);

    ArrayList<DataMap> settings = new ArrayList<>();
    DataMap settingsDataMap = getSettingsDataMap();
    settings.add(settingsDataMap);

    if (connectionResult.isSuccess() && googleApiClient.isConnected() && settings.size() > 0) {

        PutDataMapRequest dataMap = PutDataMapRequest.create(WearableConstants.SETTINGS_PATH);
        dataMap.getDataMap().putDataMapArrayList(WearableConstants.EXTRA_SETTINGS, settings);
        PutDataRequest request = dataMap.asPutDataRequest();

        // Send the data over
        DataApi.DataItemResult result = Wearable.DataApi.putDataItem(googleApiClient, request).await();

        if (!result.getStatus().isSuccess()) {
            Log.e("", String.format("Error sending settings using DataApi (error code = %d)",
                    result.getStatus().getStatusCode()));
        } else {
            Log.d("Updated settings sent");
        }

    } else {
        // GoogleApiClient connection error
        Log.e("Error connecting GoogleApiClient");
    }
}
 
Example #28
Source File: MainActivity.java    From android-google-accounts with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a client using AutoManage functionality.
 */
protected synchronized void rebuildGoogleApiClient() {
    // When we build the GoogleApiClient we specify where connected and connection failed
    // callbacks should be returned, which Google APIs our app uses and which OAuth 2.0
    // scopes our app requests. When using enableAutoManage to register the failed connection
    // listener it will only be called back when auto-resolution attempts were not
    // successful or possible. A normal ConnectionFailedListener is also registered below to
    // notify the activity when it needs to stop making API calls.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */,
                    0 /* googleApiClientId used when auto-managing multiple googleApiClients */,
                    this /* OnConnectionFailedListener */)
            .addConnectionCallbacks(this /* ConnectionCallbacks */)
            // Register a connection listener that will notify on disconnect (including ones
            // caused by calling disconnect on the GoogleApiClient).
            .addOnConnectionFailedListener(new OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult connectionResult) {
                    googleApiClientConnectionStateChange(true);
                }
            })
            .addApi(Plus.API)
            .addScope(new Scope(Scopes.PLUS_ME))
                    // TODO(developer): Specify any additional API Scopes or APIs you need here.
                    // The GoogleApiClient will ensure these APIs are available, and the Scopes
                    // are approved before invoking the onConnected callbacks.
            .build();
}
 
Example #29
Source File: GooglePlayServices.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@Override
public void startConnectionResultResolution(ConnectionResult result, Activity activity) throws IntentSender.SendIntentException{
    try {
        result.startResolutionForResult(activity, REQUEST_OAUTH);
    }catch (IntentSender.SendIntentException e) {
        throw e;
    }
}
 
Example #30
Source File: ActivityRecognitionServiceCommandTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testServiceStoppedMessageReceivedOnlyOnce() throws Exception {
    when(_playServices.isGooglePlayServicesAvailable(any(Context.class))).thenReturn(ConnectionResult.SUCCESS);

    _command.execute(_app);
    _command.onChangeState(new ActivityRecognitionChangeState(BaseChangeState.State.STOP));
    _command.onChangeState(new ActivityRecognitionChangeState(BaseChangeState.State.STOP));

    ArgumentCaptor<ActivityRecognitionStatus> captor = ArgumentCaptor.forClass(ActivityRecognitionStatus.class);
    verify(_bus,timeout(1000).times(1)).post(captor.capture());

    assertEquals(BaseStatus.Status.STOPPED, captor.getValue().getStatus());
}