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:com.darshancomputing.BatteryIndicatorPro.BatteryInfoService.java

public static void onWidgetUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    widgetManager = appWidgetManager;//from   w  w w.  j a  va2 s .  com

    for (int i = 0; i < appWidgetIds.length; i++) {
        widgetIds.add(appWidgetIds[i]);
    }

    context.startService(new Intent(context, BatteryInfoService.class));
}

From source file:in.co.recex.detainseventyfive.BroadcastRec.java

@Override
public void onReceive(Context context, Intent intent) {
    Intent service1 = new Intent(context, NotificationGenerator.class);
    context.startService(service1);
    context.stopService(service1);//from ww w.  j  av a  2  s. c om
}

From source file:com.ui.UiActivity.java

public void startServiceActivity(Context context, Intent intent) {
    context.startService(intent);
}

From source file:org.alfresco.mobile.android.application.operations.sync.SynchroManager.java

public static SynchroManager getInstance(Context context) {
    synchronized (mLock) {
        if (mInstance == null) {
            mInstance = new SynchroManager(context.getApplicationContext());
            context.startService(new Intent(context, SynchroService.class).putExtra("t", true));
        }/*from   w w w  .  j  ava 2  s  . co m*/

        return (SynchroManager) mInstance;
    }
}

From source file:com.clockworkmod.billing.BillingReceiver.java

/**
 * This is the entry point for all asynchronous messages sent from Android Market to
 * the application. This method forwards the messages on to the
 * {@link BillingService}, which handles the communication back to Android Market.
 * The {@link BillingService} also reports state changes back to the application through
 * the {@link ResponseHandler}./*from w  ww  .ja v a  2s  .  co m*/
 */
@Override
public void onReceive(final Context context, Intent intent) {
    intent.setClass(context, BillingService.class);
    context.startService(intent);
}

From source file:com.android.bleserver.AdvertiserFragment.java

/**
 * Starts BLE Advertising by starting {@code AdvertiserService}.
 *//* www.j a  v  a 2 s . c om*/
private void startAdvertising() {
    Context c = getActivity();
    c.startService(getServiceIntent(c));
}

From source file:id.satusatudua.sigap.service.LocationReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    if (!BenihUtils.isMyServiceRunning(context, LocationService.class)) {
        context.startService(new Intent(context, LocationService.class));
    }/*from   w  w w.  j av a2  s  .com*/

    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    boolean anyLocationProv = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    anyLocationProv |= locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if (!anyLocationProv) {
        Notification notification = new NotificationCompat.Builder(context).setContentTitle("Sigap")
                .setContentText("Fitur lokasi tidak aktif.")
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher))
                .setSmallIcon(R.mipmap.ic_launcher).setOngoing(true).setAutoCancel(true)
                .setStyle(new android.support.v4.app.NotificationCompat.BigTextStyle()
                        .bigText("Aktifkan fitur lokasi agar Sigap bisa berjalan dengan baik."))
                .build();

        NotificationManagerCompat.from(SigapApp.pluck().getApplicationContext()).notify(25061993, notification);
    } else {
        NotificationManagerCompat.from(SigapApp.pluck().getApplicationContext()).cancel(25061993);
    }
}

From source file:com.linkbubble.MainApplication.java

public static void restoreLinks(Context context, String[] urls) {
    context = context.getApplicationContext();
    if (urls == null || urls.length == 0) {
        return;//from w ww. j av  a2 s  . c o m
    }
    CrashTracking.log("MainApplication.restoreLinks(), urls.length:" + urls.length);
    Intent serviceIntent = new Intent(context, MainService.class);
    serviceIntent.putExtra("cmd", "restore");
    serviceIntent.putExtra("urls", urls);
    serviceIntent.putExtra("start_time", System.currentTimeMillis());
    context.startService(serviceIntent);
}

From source file:com.trigger_context.Main_Activity.java

private void Start_MainService() {
    if (Main_Service.main_Service != null) {
        return;/*w  w w .ja  v  a 2s .  c om*/
    }
    Context x = getBaseContext();
    Intent startServiceIntent = new Intent(x, Main_Service.class);
    x.startService(startServiceIntent);
    Toast.makeText(x, "Starting Main_Service", Toast.LENGTH_LONG).show();
}

From source file:de.schildbach.wallet.service.BlockchainService.java

public static void broadcastTransaction(final Context context, final Transaction tx) {
    final Intent intent = new Intent(BlockchainService.ACTION_BROADCAST_TRANSACTION, null, context,
            BlockchainService.class);
    intent.putExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH, tx.getHash().getBytes());
    context.startService(intent);
}