List of usage examples for android.content Context startService
@Nullable public abstract ComponentName startService(Intent service);
From source file:com.example.unzi.findalert.gcm.RegistrationIntentService.java
/** * Starts this service with the given parameters. If the service is * already performing a task this action will be queued. * * @see IntentService/*from ww w . j a va 2s. co m*/ */ public static void startGCMRegistration(Context context, String locale, String macAddress, String googleAccount) { Intent intent = new Intent(context, RegistrationIntentService.class); intent.putExtra(EXTRA_LOCALE, locale); intent.putExtra(EXTRA_MAC, macAddress); intent.putExtra(EXTRA_EMAIL, googleAccount); context.startService(intent); }
From source file:org.mozilla.focus.session.SessionNotificationService.java
static void start(Context context) { final Intent intent = new Intent(context, SessionNotificationService.class); intent.setAction(ACTION_START);// www .java 2 s. co m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(intent); } else { context.startService(intent); } }
From source file:com.android.contacts.SimImportService.java
/** * Starts an import of the contacts from the sim into the target account * * @param context context to use for starting the service * @param subscriptionId the subscriptionId of the SIM card that is being imported. See * {@link android.telephony.SubscriptionInfo#getSubscriptionId()}. * Upon completion the SIM for that subscription ID will be marked as * imported/*from w w w. j a v a 2s .co m*/ * @param contacts the contacts to import * @param targetAccount the account import the contacts into */ public static void startImport(Context context, int subscriptionId, ArrayList<SimContact> contacts, AccountWithDataSet targetAccount) { context.startService(new Intent(context, SimImportService.class).putExtra(EXTRA_SIM_CONTACTS, contacts) .putExtra(EXTRA_SIM_SUBSCRIPTION_ID, subscriptionId).putExtra(EXTRA_ACCOUNT, targetAccount)); }
From source file:eu.inmite.apps.smsjizdenka.service.UpdateService.java
public static void call(Context context, boolean force) { final Intent i = new Intent(context, UpdateService.class); i.putExtra("force", force); context.startService(i); }
From source file:androidx.media.session.MediaButtonReceiver.java
private static void startForegroundService(Context context, Intent intent) { if (Build.VERSION.SDK_INT >= 26) { context.startForegroundService(intent); } else {//from w w w . ja va 2 s . co m context.startService(intent); } }
From source file:com.securecomcode.text.service.KeyCachingService.java
public static void registerPassphraseActivityStopped(Context activity) { Intent intent = new Intent(activity, KeyCachingService.class); intent.setAction(KeyCachingService.ACTIVITY_STOP_EVENT); activity.startService(intent); }
From source file:com.securecomcode.text.service.KeyCachingService.java
public static void registerPassphraseActivityStarted(Context activity) { Intent intent = new Intent(activity, KeyCachingService.class); intent.setAction(KeyCachingService.ACTIVITY_START_EVENT); activity.startService(intent); }
From source file:com.doctoror.surprise.SurpriseService.java
public static void executeSurprise(final Context context, final boolean fromUser) { final Intent intent = new Intent(context, SurpriseService.class); intent.setAction(ACTION_SURPRISE);// w ww .j a v a 2s .c om intent.putExtra(EXTRA_FROM_USER, fromUser); context.startService(intent); }
From source file:com.commonsware.android.service.lifecycle.DemoService.java
static void startMeUp(Context ctxt, boolean foreground, boolean importantish) { Intent i = new Intent(ctxt, DemoService.class).putExtra(EXTRA_FOREGROUND, foreground) .putExtra(EXTRA_IMPORTANTISH, importantish); if (foreground && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { ctxt.startForegroundService(i);//w w w .j a v a 2 s .c om } else { ctxt.startService(i); } }
From source file:com.finchuk.clock2.timers.TimerNotificationService.java
/** * Helper method to start this Service for its default action: to show * the notification for the Timer with the given id. *///from w w w. j ava 2 s . com public static void showNotification(Context context, Timer timer) { Intent intent = new Intent(context, TimerNotificationService.class); intent.putExtra(EXTRA_TIMER, ParcelableUtil.marshall(timer)); context.startService(intent); }