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.androidServices.LocationService.java

public static void run1min(Context context) {

    if (serviceRunning || !MainApplication.visible) {
        return; // If service is running or user is not visible, stop
    }/*from  w  ww  . j a va 2 s  .co m*/
    Log.d(TAG, "run1min called");
    Intent intent = new Intent(context, LocationService.class);
    intent.putExtra(RUN_1_MIN, 1);
    context.startService(intent);
}

From source file:com.jtechme.apphub.UpdateService.java

public static void updateRepoNow(String address, Context context) {
    Intent intent = new Intent(context, UpdateService.class);
    intent.putExtra(EXTRA_MANUAL_UPDATE, true);
    if (!TextUtils.isEmpty(address)) {
        intent.putExtra(EXTRA_ADDRESS, address);
    }// w w w. j  av a2  s. com
    context.startService(intent);
}

From source file:com.bangz.smartmute.services.LocationMuteService.java

public static void addGeofence(Context context, Uri uri) {

    Intent intent = new Intent(ACTION_ADD_GEOFENCE, uri, context, LocationMuteService.class);
    LogUtils.LOGD(TAG, " Pending add one geofence. id = " + ContentUris.parseId(uri));
    context.startService(intent);
}

From source file:com.google.android.gcm.GCMRegistrar.java

static void internalUnregister(Context context) {
    Log.v(TAG, "Unregistering app " + context.getPackageName());
    Intent intent = new Intent(GCMConstants.INTENT_TO_GCM_UNREGISTRATION);
    intent.setPackage(GSF_PACKAGE);//from w w w.  j  a  v  a2 s  .co m
    intent.putExtra(GCMConstants.EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    context.startService(intent);
}

From source file:com.bangz.smartmute.services.LocationMuteService.java

public static void removeGeofence(Context context, Uri uri) {
    Intent intent = new Intent(ACTION_REMOVE_GEOFENCE, uri, context, LocationMuteService.class);
    LogUtils.LOGD(TAG, "Pending remove one geofence. id = " + ContentUris.parseId(uri));
    context.startService(intent);
}

From source file:cn.sharesdk.analysis.EventManager.java

private static void isServiceConnect(Context context) {
    Ln.e("isServiceConnect ==>>", "bindService");
    if (context != null) {
        Intent service = new Intent(context, RemoteService.class);
        service.setAction("cn.sharesdk.analysis.server.AIDLService");
        context.startService(service);
        context.bindService(service, connection, Context.BIND_AUTO_CREATE);
    }/*ww w.j  ava2 s . co m*/
}

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

public static void syncFit(Context context) {
    if (context.getSharedPreferences(Constants.USER_SHARED_PREFERENCES, 0)
            .getBoolean(Constants.GOOGLE_FIT_ENABLED, false)) {
        Intent insertIntent = new Intent(context, GoogleFitService.class);
        insertIntent.setAction("InsertData");
        context.startService(insertIntent);
    }/*from w ww.j a  va  2s .com*/
}

From source file:org.sufficientlysecure.keychain.service.PassphraseCacheService.java

/**
 * This caches a new passphrase in memory by sending a new command to the service. An android
 * service is only run once. Thus, when the service is already started, new commands just add
 * new events to the alarm manager for new passphrases to let them timeout in the future.
 *
 * @param context//w  w w  . j av  a 2 s  .com
 * @param keyId
 * @param passphrase
 */
public static void addCachedPassphrase(Context context, long keyId, String passphrase) {
    Log.d(TAG, "cacheNewPassphrase() for " + keyId);

    Intent intent = new Intent(context, PassphraseCacheService.class);
    intent.setAction(ACTION_PASSPHRASE_CACHE_ADD);
    intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassphraseCacheTtl());
    intent.putExtra(EXTRA_PASSPHRASE, passphrase);
    intent.putExtra(EXTRA_KEY_ID, keyId);

    context.startService(intent);
}

From source file:cz.maresmar.sfm.service.plugin.sync.SyncHandler.java

/**
 * Starts full menu sync as {@link IntentService}
 *
 * @param context Some valid context/* ww w .  j av a2 s  .co  m*/
 */
public static void startFullSync(@NonNull Context context) {
    Intent intent = new Intent(context, SyncHandleIntentService.class);
    intent.putExtra(ACTION, ACTION_FULL_SYNC);
    context.startService(intent);
}

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

public static void getBootFitSync(Context context) {
    if (context.getSharedPreferences(Constants.USER_SHARED_PREFERENCES, 0)
            .getBoolean(Constants.GOOGLE_FIT_AUTHORIZED, false)) {
        Intent insertIntent = new Intent(context, GoogleFitService.class);
        insertIntent.setAction("GetOldestSession");
        context.startService(insertIntent);
    }//from w  ww .ja v a2  s  . c o m
}