Example usage for android.app Activity stopService

List of usage examples for android.app Activity stopService

Introduction

In this page you can find the example usage for android.app Activity stopService.

Prototype

@Override
    public boolean stopService(Intent name) 

Source Link

Usage

From source file:Main.java

/**
 * Function to stop a service.//from  w  ww  .j  a  v a2  s  .c  o  m
 *
 * @param cls The service's class.
 */
public static void stopService(Class<?> cls, Activity activity) {
    if (serviceIsRunning(cls, activity)) {
        activity.stopService(new Intent(activity, cls));
        Log.d("Utils Service", "Service Stopped");
    }
}

From source file:com.marianhello.cordova.bgloc.BackgroundGpsPlugin.java

/**
 * Override method in CordovaPlugin./*  w  ww  .j  a  v  a2  s .co  m*/
 * Checks to see if it should turn off
 */
public void onDestroy() {
    Activity activity = this.cordova.getActivity();

    if (isEnabled && stopOnTerminate.equalsIgnoreCase("true")) {
        activity.stopService(updateServiceIntent);
    }
}

From source file:me.tassoevan.cordova.BackgroundPlugin.java

private void stopService() {
    Activity context = cordova.getActivity();

    Intent intent = new Intent(context, ForegroundService.class);

    if (isBind) {
        context.unbindService(connection);
    }//from   ww  w. j  a v  a  2s  . c  om

    context.stopService(intent);

    isBind = false;
}

From source file:com.gbaldera.tipaypal.TipaypalModule.java

@Override
public void onDestroy(Activity activity) {
    // This method is called when the root context is being destroyed
    activity.stopService(new Intent(activity, PayPalService.class));

    Log.d(TAG, "[MODULE LIFECYCLE EVENT] destroy");
    super.onDestroy(activity);
}

From source file:com.tenforwardconsulting.cordova.bgloc.BackgroundGeolocationPlugin.java

public boolean stopBackgroundService() {
    if (!isEnabled) {
        return false;
    }/*  www  .  j  a v a 2s  .c  o m*/

    Log.d(TAG, "Stopping bg service");
    Activity activity = this.cordova.getActivity();
    isEnabled = false;
    return activity.stopService(locationServiceIntent);
}

From source file:com.gbaldera.tipaypal.TipaypalModule.java

@Kroll.method
public void initialize(HashMap params) {
    KrollDict dict = new KrollDict(params);

    client_id = TiConvert.toString(dict, PARAM_CLIENT_ID);
    receiver_email = TiConvert.toString(dict, PARAM_RECEIVER_EMAIL);
    environment = TiConvert.toString(dict, PARAM_ENVIRONMENT);
    skip_credit_card = TiConvert.toBoolean(dict, PARAM_SKIP_CREDIT_CARD, false);

    if (environment == null) {
        environment = ENVIRONMENT_NO_NETWORK;
    }/*  w w w  . j  a  v  a  2  s.c o  m*/

    if (client_id == null || receiver_email == null) {
        Log.w(TAG, "The CLIENT ID and RECEIVER EMAIL params are required");
        return;
    }

    Log.d(TAG, PARAM_ENVIRONMENT + ": " + environment);

    Activity currentActivity = TiApplication.getAppCurrentActivity();
    Intent intent = new Intent(currentActivity, PayPalService.class);

    if (isPayPalServiceRunning()) // if the service is already running stop it first
    {
        currentActivity.stopService(intent);
    }

    // set to PaymentActivity.ENVIRONMENT_PRODUCTION to move real money.
    // set to PaymentActivity.ENVIRONMENT_SANDBOX to use your test credentials from https://developer.paypal.com
    // set to PaymentActivity.ENVIRONMENT_NO_NETWORK to kick the tires without communicating to PayPal's servers.
    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, environment);

    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, receiver_email);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, client_id);

    currentActivity.startService(intent);
}

From source file:de.appplant.cordova.plugin.background.BackgroundMode.java

/**
 * Bind the activity to a background service and put them into foreground
 * state.//ww w. ja  v  a2s. c o  m
 */
private void stopService() {
    Activity context = cordova.getActivity();

    Intent intent = new Intent(context, ForegroundService.class);

    if (!isBind)
        return;

    fireEvent(Event.DEACTIVATE, null);

    context.unbindService(connection);
    context.stopService(intent);

    isBind = false;
}

From source file:com.SmartDial.BackgroundMode.java

/**
 * Bind the activity to a background service and put them into foreground
 * state.// w  w w .  jav  a2  s. co m
 */
private void stopService() {
    Activity context = this.cordova.getActivity();

    Intent intent = new Intent(context, ForegroundService.class);

    if (!isBind)
        return;

    fireEvent(Event.DEACTIVATE, null);

    context.unbindService(connection);
    context.stopService(intent);

    isBind = false;
}

From source file:com.example.scandevice.ScanDevice.java

/**
 * Bind the activity to a background service and put them into foreground
 * state./*from www .ja  va2 s  .  c  o  m*/
 */
private void stopService() {
    Activity context = cordova.getActivity();

    Intent wifiIntent = new Intent(context, WifiScanService.class);
    Intent bluetooth = new Intent(context, BluetoothScanService.class);

    if (!isBind)
        return;
    context.unbindService(connection);
    context.stopService(wifiIntent);
    context.unbindService(connection2);
    context.stopService(bluetooth);
    isBind = false;
}

From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java

protected void stopBackgroundService() {
    if (isServiceRunning) {
        log.info("Stopping bg service");
        Activity activity = getActivity();
        activity.stopService(new Intent(activity, LocationService.class));
        isServiceRunning = false;/*from  www .ja v  a  2 s.c  o m*/
    }
}