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:org.fdroid.fdroid.net.DownloaderService.java

/**
 * Remove a URL to the download queue, even if it is currently downloading.
 * <p/>//ww w .j a  v  a2  s  .  c  o  m
 * All notifications are sent as an {@link Intent} via local broadcasts to be received by
 *
 * @param context
 * @param urlString The URL to remove from the download queue
 * @see #queue(Context, String, String)
 */
public static void cancel(Context context, String urlString) {
    Utils.debugLog(TAG, "Preparing cancellation of " + urlString + " download");
    Intent intent = new Intent(context, DownloaderService.class);
    intent.setAction(ACTION_CANCEL);
    intent.setData(Uri.parse(urlString));
    context.startService(intent);
}

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

public static void scrobbleIfPossible(Context ctx, NetApp napp, int numInCache) {
    if (numInCache > 0) {
        Intent intent = new Intent(ctx, ScrobblingService.class);
        intent.setAction(ScrobblingService.ACTION_JUSTSCROBBLE);
        intent.putExtra("netapp", napp.getIntentExtraValue());
        ctx.startService(intent);
    } else {/* ww w.j a v a 2 s .co  m*/
        Toast.makeText(ctx, ctx.getString(R.string.no_scrobbles_in_cache), Toast.LENGTH_LONG).show();
    }
}

From source file:nl.sogeti.android.gpstracker.integration.GPSLoggerServiceManager.java

public static void setStreaming(Context context, boolean isStreaming, float distance, long time) {
    Intent intent = createServiceIntent();
    intent.putExtra(ExternalConstants.Commands.CONFIG_STREAM_BROADCAST, isStreaming);
    intent.putExtra(ExternalConstants.Commands.CONFIG_STREAM_INTERVAL_DISTANCE, distance);
    intent.putExtra(ExternalConstants.Commands.CONFIG_STREAM_INTERVAL_TIME, time);
    context.startService(intent);
}

From source file:cc.softwarefactory.lokki.android.androidServices.LocationService.java

public static void start(Context context) {

    Log.d(TAG, "start Service called");

    placeService = new PlaceService(context);

    if (serviceRunning) { // If service is running, no need to start it again.
        Log.w(TAG, "Service already running...");
        return;//ww w.  j a v a2 s .  c  om
    }
    context.startService(new Intent(context, LocationService.class));

}

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

public static void shutdownGeofences(Context context) {
    Intent intent = new Intent(ACTION_SHUTDOWN_GEOFENCES, null, context, LocationMuteService.class);
    LogUtils.LOGD(TAG, "Pending shutdown geofences.");
    context.startService(intent);
}

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

public static void startAll(Context context) {
    Intent intent = new Intent(ACTION_START_GEOFENCES, null, context, LocationMuteService.class);
    LogUtils.LOGD(TAG, "Pending start geofences service.");
    context.startService(intent);
}

From source file:org.smssecure.smssecure.service.KeyCachingService.java

public static synchronized MasterSecret getMasterSecret(Context context) {
    if (masterSecret == null && SilencePreferences.isPasswordDisabled(context)) {
        try {//from  ww w. j av  a2 s .  c o m
            MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(context,
                    MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
            Intent intent = new Intent(context, KeyCachingService.class);

            context.startService(intent);

            return masterSecret;
        } catch (InvalidPassphraseException e) {
            Log.w("KeyCachingService", e);
        }
    }

    return masterSecret;
}

From source file:org.thoughtcrime.SMP.service.KeyCachingService.java

public static synchronized MasterSecret getMasterSecret(Context context) {
    if (masterSecret == null && TextSecurePreferences.isPasswordDisabled(context)) {
        try {//from  ww  w .j  a  v  a 2s.c  om
            MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(context,
                    MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
            Intent intent = new Intent(context, KeyCachingService.class);

            context.startService(intent);

            return masterSecret;
        } catch (InvalidPassphraseException e) {
            Log.w("KeyCachingService", e);
        }
    }

    return masterSecret;
}

From source file:eu.andlabs.studiolounge.gcp.GCPService.java

public static Lounge bind(Context ctx) {
    Log.d("GCP-Service", "binding GCP Service");
    String name = LoginManager.getInstance(ctx).getUserId().getPlayername();
    Lounge lounge = new Lounge(ctx);
    Intent intent = new Intent(ctx, GCPService.class);
    intent.putExtra("packageName", ctx.getPackageName());
    intent.putExtra("messenger", lounge.mMessenger);
    intent.putExtra("name", name);
    ctx.startService(intent);
    ctx.bindService(intent, lounge, Context.BIND_AUTO_CREATE);
    return lounge;
}

From source file:com.tingtingapps.securesms.service.KeyCachingService.java

public static synchronized @Nullable MasterSecret getMasterSecret(Context context) {
    if (masterSecret == null && TextSecurePreferences.isPasswordDisabled(context)) {
        try {//from w  w w  . j  av a2  s .  co  m
            MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(context,
                    MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
            Intent intent = new Intent(context, KeyCachingService.class);

            context.startService(intent);

            return masterSecret;
        } catch (InvalidPassphraseException e) {
            Log.w("KeyCachingService", e);
        }
    }

    return masterSecret;
}