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:cc.softwarefactory.lokki.android.services.DataService.java

public static void getPlaces(Context context) {

    Log.e(TAG, "getPlaces");
    Intent placesIntent = new Intent(context, DataService.class);
    placesIntent.putExtra(GET_PLACES, 1);
    context.startService(placesIntent);
}

From source file:cc.softwarefactory.lokki.android.services.DataService.java

public static void getDashboard(Context context) {

    Log.e(TAG, "getDashboard");
    Intent placesIntent = new Intent(context, DataService.class);
    placesIntent.putExtra(ALARM_TIMER, 1);
    context.startService(placesIntent);
}

From source file:com.dgsd.android.ShiftTracker.Service.NotificationService.java

public static void requestShowAlarm(Context context, Shift shift) {
    final Intent intent = new Intent(context, NotificationService.class);
    intent.setAction(ACTION_SHOW_ALARM);
    intent.putExtra(EXTRA_SHIFT, shift);
    context.startService(intent);
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.service.OrgSyncService.java

public static void start(Context context) {
    context.startService(new Intent(context, OrgSyncService.class).setAction(ACTION_START));
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.service.OrgSyncService.java

public static void pause(Context context) {
    context.startService(new Intent(context, OrgSyncService.class).setAction(ACTION_PAUSE));
}

From source file:it.polimi.spf.framework.local.SPFService.java

/**
 * Sends an intent to SPFService, using the {@link Context} provided, that
 * makes it start in foreground./* www  .j  ava  2  s  .c  om*/
 *
 * @param c - the Context used to send the intent;
 * @see Service#startForeground(int, Notification)
 */
public static void startForeground(Context c) {
    Intent i = new Intent(c, SPFService.class);
    i.setAction(ACTION_START_FOREGROUND);
    c.startService(i);
}

From source file:it.polimi.spf.framework.local.SPFService.java

/**
 * Sends an intent to SPFService, using the {@link Context} provided, that
 * makes it stop foreground.// www.  j  a va2  s . c  om
 *
 * @param c - the Context used to send the intent;
 * @see Service#stopForeground(boolean)
 */
public static void stopForeground(Context c) {
    Intent i = new Intent(c, SPFService.class);
    i.setAction(ACTION_STOP_FOREGROUND);
    c.startService(i);
    c.stopService(i);
}

From source file:org.chromium.base.ContextUtils.java

/**
 * Starts a service with {@code Intent}.  This will be started with the foreground expectation
 * on Android O and higher./*from   www .  ja v  a  2  s.  co  m*/
 * TODO(crbug.com/769683): Temporary measure until we roll the support library to 26.1.0.
 *
 * @param context Context to start Service from.
 * @param intent The description of the Service to start.
 *
 * @see {@link android.support.v4.content.ContextCompat#startForegroundService(Context,Intent)}
 * @see Context#startForegroundService(Intent)
 * @see Context#startService(Intent)
 */
public static void startForegroundService(Context context, Intent intent) {
    if (Build.VERSION.SDK_INT >= 26) {
        context.startForegroundService(intent);
    } else {
        context.startService(intent);
    }
}

From source file:com.twentyoneechoes.borges.util.Utils.java

public static void runLibraryUpdateService(Context context) {
    Intent intent = new Intent(context, LibraryUpdateService.class);
    context.startService(intent);
}

From source file:ca.hoogit.garagepi.Controls.DoorControlService.java

public static void startActionToggle(Context context, String name) {
    Intent intent = new Intent(context, DoorControlService.class);
    intent.setAction(Consts.ACTION_DOORS_TOGGLE);
    intent.putExtra(Consts.KEY_DOOR_ID, name);
    context.startService(intent);
}