List of usage examples for android.content Context startService
@Nullable public abstract ComponentName startService(Intent service);
From source file:com.bangz.smartmute.services.LocationMuteService.java
public static void deleteGeofence(Context context, long[] ids) { Intent intent = new Intent(ACTION_DELETE_GEOFENCES, null, context, LocationMuteService.class); intent.putExtra(PARAM_KEY_IDS, ids); LogUtils.LOGD(TAG, "Pending delete geofences. id = " + ids.toString()); context.startService(intent); }
From source file:org.wahtod.wififixer.ui.MainActivity.java
private static void startwfService(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); boolean hasService = false; for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (WFMonitorService.class.getName().equals(service.service.getClassName())) { hasService = true;/* w w w . j a v a 2 s. com*/ } } if (!hasService) context.startService(new Intent(context, WFMonitorService.class)); }
From source file:com.google.android.gcm.GCMBaseIntentService.java
/** * Called from the broadcast receiver.//from w w w . j a va2 s . c o m * <p> * Will process the received intent, call handleMessage(), registered(), * etc. in background threads, with a wake lock, while keeping the service * alive. */ static void runIntentInService(Context context, Intent intent, String className) { synchronized (LOCK) { if (sWakeLock == null) { // This is called from BroadcastReceiver, there is no init. PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); sWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY); } } Log.v(TAG, "Acquiring wakelock"); sWakeLock.acquire(); intent.setClassName(context, className); context.startService(intent); }
From source file:com.google.android.apps.santatracker.presentquest.PlacesIntentService.java
public static void startNearbySearch(Context context, LatLng center, int radius) { Log.d(TAG, "startNearbySearch: radius=" + radius); Intent intent = new Intent(context, PlacesIntentService.class); intent.setAction(ACTION_SEARCH_NEARBY); intent.putExtra(EXTRA_LAT_LNG, center); intent.putExtra(EXTRA_RADIUS, radius); context.startService(intent); }
From source file:org.catnut.util.CatnutUtils.java
public static void checkout(boolean required, Context context, SharedPreferences preferences) { long now = System.currentTimeMillis(); String key = context.getString(R.string.pref_check_upgrade); if (required) { context.startService(new Intent(context, UpgradeService.class)); preferences.edit().putLong(key, now).commit(); } else {//from w ww. ja v a2 s . co m long last = preferences.getLong(key, now); if (now - last > (7 * 24 * 60 * 60 * 1000)) { // ? Log.d(TAG, "need upgrade..."); preferences.edit().putLong(key, now).commit(); context.startService(new Intent(context, UpgradeService.class)); } } }
From source file:org.wso2.app.catalog.utils.CommonUtils.java
/** * Call EMM system app in COPE mode.// w w w. j a v a 2s .c o m * @param context - Application context. * @param operation - Operation code. * @param appUri - App package/APK URI when an app operation executed. * @param appName - Application name. */ public static void callAgentApp(Context context, String operation, String appUri, String appName) { Intent intent = new Intent(Constants.AGENT_APP_SERVICE_NAME); Intent explicitIntent = createExplicitFromImplicitIntent(context, intent); if (explicitIntent != null) { intent = explicitIntent; } intent.putExtra("operation", operation); intent.setPackage(Constants.PACKAGE_NAME); if (appUri != null) { intent.putExtra("appUri", appUri); } if (appName != null) { intent.putExtra("appName", appName); } context.startService(intent); }
From source file:org.fdroid.fdroid.net.DownloaderService.java
/** * Add a URL to the download queue.//w w w . j a va2 s. c o m * <p/> * All notifications are sent as an {@link Intent} via local broadcasts to be received by * * @param context * @param packageName The packageName of the app being downloaded * @param urlString The URL to add to the download queue * @see #cancel(Context, String) */ public static void queue(Context context, String packageName, String urlString) { Utils.debugLog(TAG, "Preparing " + urlString + " to go into the download queue"); Intent intent = new Intent(context, DownloaderService.class); intent.setAction(ACTION_QUEUE); intent.setData(Uri.parse(urlString)); if (!TextUtils.isEmpty(packageName)) { intent.putExtra(EXTRA_PACKAGE_NAME, packageName); } context.startService(intent); }
From source file:org.wso2.iot.agent.utils.CommonUtils.java
public static Location getLocation(Context context) { Intent serviceIntent = new Intent(context, LocationService.class); context.startService(serviceIntent); return LocationUpdateReceiver.getLocation(); }
From source file:cz.maresmar.sfm.service.plugin.sync.SyncHandler.java
/** * Starts sync of remaining food in menu for specific user as {@link IntentService} * <p>/*from w w w . jav a2 s . c o m*/ * This could optimally save some mobile data. * </p> * * @param userId ID of user that will be synced * @param context Some valid context */ public static void startRemainingSync(@NonNull Context context, long userId) { Intent intent = new Intent(context, SyncHandleIntentService.class); intent.putExtra(ACTION, ACTION_REMAINING_SYNC); intent.putExtra(EXTRA_USER_ID, userId); context.startService(intent); }
From source file:eu.faircode.netguard.SinkholeService.java
public static void reload(String network, Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (prefs.getBoolean("enabled", false)) if (network == null || ("wifi".equals(network) ? !Util.isMetered(context) : Util.isMetered(context))) { Intent intent = new Intent(context, SinkholeService.class); intent.putExtra(EXTRA_COMMAND, Command.reload); context.startService(intent); }/*from w ww. j a v a2 s. c o m*/ }