Example usage for android.app Activity startService

List of usage examples for android.app Activity startService

Introduction

In this page you can find the example usage for android.app Activity startService.

Prototype

@Override
    public ComponentName startService(Intent service) 

Source Link

Usage

From source file:Main.java

/**
 * Function to start a service.//from  ww w.ja v  a2  s  . co  m
 *
 * @param cls The service's class.
 */
public static void startService(Class<?> cls, Activity activity) {
    if (!serviceIsRunning(cls, activity)) {
        activity.startService(new Intent(activity, cls));
        Log.d("Utils Service", "Service Started");
    }
}

From source file:info.martinmarinov.dvbservice.DvbService.java

static void requestOpen(Activity activity, DeviceFilter deviceFilter) {
    Intent intent = new Intent(activity, DvbService.class).putExtra(DEVICE_FILTER, deviceFilter);
    activity.startService(intent);
}

From source file:com.github.kimikage.uguisuan.WavePlayerService.java

public static void stop(Activity activity) {
    Intent intent = new Intent(activity, WavePlayerService.class);
    intent.putExtra(ARG_ACTION, Receiver.ACTION_STOP);
    activity.startService(intent);
}

From source file:com.geekandroid.sdk.update.NotificationService.java

public static void startService(Activity activity, String url, String name, String fileDir) {
    Intent intent = new Intent(activity, NotificationService.class);
    activity.startService(intent);
    mActivity = activity;//from   ww w  . ja v a2 s.  c  o  m
    serverURL = url;
    fileName = name;
    mfileDir = fileDir;
}

From source file:email.schaal.ocreader.service.SyncService.java

public static void startSync(Activity activity, boolean initialSync) {
    Intent syncIntent = new Intent(ACTION_FULL_SYNC, null, activity, SyncService.class);
    syncIntent.putExtra(EXTRA_INITIAL_SYNC, initialSync);
    activity.startService(syncIntent);
}

From source file:com.github.kimikage.uguisuan.WaveReaderService.java

public static void start(Activity activity, String filePath) {
    Intent intent = new Intent(activity, WaveReaderService.class);
    intent.putExtra(ARG_FILE_PATH, filePath);
    activity.startService(intent);
}

From source file:barqsoft.footballscores.utils.FootballUtils.java

/**
 * method to fetch football details using intent
 *
 * @param context  application context// w  ww  .ja v  a2  s . c om
 * @param activity from which we called.
 */
public static void fetchFootballData(@NonNull Context context, @NonNull Activity activity) {
    if (Utility.isNetworkAvailable(context)) {
        Intent intent = new Intent(activity, FootballFetchService.class);
        intent.setAction(Constants.FETCH_INFO);
        activity.startService(intent);
    } else {
        Toast.makeText(context, context.getString(R.string.no_internet_connection), Toast.LENGTH_SHORT).show();
    }
}

From source file:email.schaal.ocreader.service.SyncService.java

public static void startLoadMore(Activity activity, long id, long offset, boolean isFeed) {
    Intent loadMoreIntent = new Intent(ACTION_LOAD_MORE, null, activity, SyncService.class);
    loadMoreIntent.putExtra(EXTRA_ID, id);
    loadMoreIntent.putExtra(EXTRA_OFFSET, offset);
    loadMoreIntent.putExtra(EXTRA_IS_FEED, isFeed);
    activity.startService(loadMoreIntent);
}

From source file:com.github.kimikage.uguisuan.WavePlayerService.java

public static void start(Activity activity) {

    UguisuAnne app = (UguisuAnne) (activity.getApplicationContext());
    if (app.getSourceWave() == null || app.getSourceWave().getPcm() == null) {
        update(-1);/*from   w w  w.  j  a  va 2  s  .c o m*/
        return;
    }

    Intent intent = new Intent(activity, WavePlayerService.class);
    intent.putExtra(ARG_ACTION, Receiver.ACTION_START);
    activity.startService(intent);
}

From source file:com.google.samples.apps.iosched.settings.SettingsActivity.java

static void scheduleCalendarSync(Activity activity) {
    Intent intent;/*from  w w  w.  j a va 2  s.  co  m*/
    if (SettingsUtils.shouldSyncCalendar(activity)) {
        // Add all calendar entries
        intent = new Intent(SessionCalendarService.ACTION_UPDATE_ALL_SESSIONS_CALENDAR);
    } else {
        // Remove all calendar entries
        intent = new Intent(SessionCalendarService.ACTION_CLEAR_ALL_SESSIONS_CALENDAR);
    }

    intent.setClass(activity, SessionCalendarService.class);
    activity.startService(intent);
}