Example usage for android.content Context startService

List of usage examples for android.content Context startService

Introduction

In this page you can find the example usage for android.content Context startService.

Prototype

@Nullable
public abstract ComponentName startService(Intent service);

Source Link

Document

Request that a given application service be started.

Usage

From source file:name.marinchenko.lorryvision.util.Initializer.java

public static void initNetScanService(final Context context) {
    DefaultExecutorSupplier.getInstance().forBackgroundTasks().execute(new Runnable() {
        @Override//ww w  .j a  v a2  s  . c  o m
        public void run() {
            final Intent serviceIntent = new Intent(context, NetScanService.class);
            final boolean auto = isAutoUpdate(context);

            serviceIntent.setAction(auto ? ACTION_SCAN_START : ACTION_SCAN_STOP);
            context.startService(serviceIntent);
        }
    });
}

From source file:com.asburymotors.android.disneysocal.service.UtilityService.java

public static void triggerWearTest(Context context, boolean microApp) {
    Intent intent = new Intent(context, UtilityService.class);
    intent.setAction(UtilityService.ACTION_FAKE_UPDATE);
    intent.putExtra(EXTRA_TEST_MICROAPP, microApp);
    context.startService(intent);
}

From source file:com.battlelancer.seriesguide.util.Utils.java

/**
 * Run the notification service to display and (re)schedule upcoming episode alarms.
 *//*from   w  w  w  .j av  a2s. c om*/
public static void runNotificationService(Context context) {
    Intent i = new Intent(context, NotificationService.class);
    context.startService(i);
}

From source file:com.sean.takeastand.util.Utils.java

public static void endSession(Context context) {
    Intent stopStepCounterIntent = new Intent(context, StandDtectorTM.class);
    stopStepCounterIntent.setAction(com.heckbot.standdtector.Constants.STOP_DEVICE_STEP_COUNTER);
    context.startService(stopStepCounterIntent);
    syncFit(context);//from  www .ja va  2  s  .  c  om
}

From source file:com.nononsenseapps.feeder.model.RssSyncHelper.java

public static void uploadFeedAsync(Context context, long id, String title, String link, String tag) {
    Intent intent = new Intent(context, RssSyncHelper.class);
    intent.setAction(ACTION_PUT_FEED);/*from   ww  w  . j  av  a  2  s.  c om*/
    intent.putExtra("id", id);
    intent.putExtra("title", title);
    intent.putExtra("link", link);
    intent.putExtra("tag", tag);
    context.startService(intent);
}

From source file:ch.carteggio.provider.sync.NotificationService.java

public static void setSendingError(Context c, boolean error, String message) {

    Intent service = new Intent(c, NotificationService.class);
    service.setAction(UPDATE_SENDING_STATE_ACTION);
    service.putExtra(FAILURE_EXTRA, error);

    if (error) {//from  w  ww.  j a v a 2s .  co m
        service.putExtra(FAILURE_MESSAGE_EXTRA, message);
    }

    c.startService(service);

}

From source file:ch.carteggio.provider.sync.NotificationService.java

public static void setReceivingError(Context c, boolean error, String message) {

    Intent service = new Intent(c, NotificationService.class);
    service.setAction(UPDATE_RECEIVING_STATE_ACTION);
    service.putExtra(FAILURE_EXTRA, error);

    if (error) {//from   w w w.j  a v a 2s  .  c o m
        service.putExtra(FAILURE_MESSAGE_EXTRA, message);
    }

    c.startService(service);

}

From source file:com.adam.aslfms.util.Util.java

public static void scrobbleAllIfPossible(Context ctx, int numInCache) {
    if (numInCache > 0) {
        Intent service = new Intent(ctx, ScrobblingService.class);
        service.setAction(ScrobblingService.ACTION_JUSTSCROBBLE);
        service.putExtra("scrobbleall", true);
        ctx.startService(service);
    } else {// w  ww  .ja v a2 s  .c  o  m
        Toast.makeText(ctx, ctx.getString(R.string.no_scrobbles_in_cache), Toast.LENGTH_LONG).show();
    }
}

From source file:eu.chainfire.geolog.service.BackgroundService.java

public static void startService(Context context) {
    context.startService(new Intent(context.getApplicationContext(), BackgroundService.class));
}

From source file:name.marinchenko.lorryvision.util.Initializer.java

public static void initAutoConnect(final Context context) {
    DefaultExecutorSupplier.getInstance().forBackgroundTasks().execute(new Runnable() {
        @Override//  www .  j  a va  2  s .  c  o  m
        public void run() {
            final Intent serviceIntent = new Intent(context, NetScanService.class);
            final boolean auto = isAutoConnect(context);

            serviceIntent.setAction(ACTION_CONNECT_AUTO);
            serviceIntent.putExtra(EXTRA_CONNECT_AUTO, auto);
            context.startService(serviceIntent);
        }
    });
}