List of usage examples for android.content Context startService
@Nullable public abstract ComponentName startService(Intent service);
From source file:com.owncloud.android.services.observer.FileObserverService.java
/** * Requests to start or stop the observance of a given file. * /*www. j av a 2 s . c o m*/ * @param context Android context of the caller component. * @param file OCFile to start or stop to watch. * @param account OC account containing file. * @param watchIt 'True' creates an intent to watch, 'false' an intent to stop watching. */ public static void observeFile(Context context, OCFile file, Account account, boolean watchIt) { Intent intent = new Intent(context, FileObserverService.class); intent.setAction(watchIt ? FileObserverService.ACTION_ADD_OBSERVED_FILE : FileObserverService.ACTION_DEL_OBSERVED_FILE); intent.putExtra(FileObserverService.ARG_FILE, file); intent.putExtra(FileObserverService.ARG_ACCOUNT, account); context.startService(intent); }
From source file:org.zywx.wbpalmstar.platform.push.report.PushReportAgent.java
/** * ?//from ww w .j ava 2s .c o m * * @param type 1 0 */ public static void setPushState(Context context, int type) { PushReportUtility.log("setPushState--" + type); SharedPreferences sp = context.getSharedPreferences("saveData", Context.MODE_MULTI_PROCESS); Editor editor = sp.edit(); editor.putString("localPushMes", String.valueOf(type)); editor.commit(); String pushMes = sp.getString("pushMes", String.valueOf(type)); if (type == 1 && "1".equals(pushMes)) { Intent myIntent = new Intent(context, PushService.class); myIntent.putExtra("type", type); context.startService(myIntent); } else { Intent myIntent = new Intent(context, PushService.class); myIntent.putExtra("type", type); context.startService(myIntent); } }
From source file:net.micode.soundrecorder.RecorderService.java
public static void startRecording(Context context, int outputfileformat, String path, boolean highQuality, long maxFileSize) { Intent intent = new Intent(context, RecorderService.class); intent.putExtra(ACTION_NAME, ACTION_START_RECORDING); intent.putExtra(ACTION_PARAM_FORMAT, outputfileformat); intent.putExtra(ACTION_PARAM_PATH, path); intent.putExtra(ACTION_PARAM_HIGH_QUALITY, highQuality); intent.putExtra(ACTION_PARAM_MAX_FILE_SIZE, maxFileSize); context.startService(intent); }
From source file:fr.inria.ucn.Helpers.java
/** * Request data upload./*from ww w .ja va 2 s . c o m*/ * * @param context * @param wl Need wakelock? */ public static void doUpload(Context context, boolean wl) { if (wl) Helpers.acquireLock(context); Intent sintent = new Intent(context, CollectorService.class); sintent.setAction(Constants.ACTION_UPLOAD); if (wl) sintent.putExtra(Constants.INTENT_EXTRA_RELEASE_WL, true); // request service to release the wl context.startService(sintent); }
From source file:fr.inria.ucn.Helpers.java
/** * Request data collection sample./*from w w w. ja v a2 s. co m*/ * * @param context * @param wl Need wakelock? */ public static void doSample(Context context, boolean wl) { if (wl) Helpers.acquireLock(context); Intent sintent = new Intent(context, CollectorService.class); sintent.setAction(Constants.ACTION_COLLECT); if (wl) sintent.putExtra(Constants.INTENT_EXTRA_RELEASE_WL, true); // request service to release the wl context.startService(sintent); }
From source file:com.sean.takeastand.util.Utils.java
public static void startStepListenerSession(Context context, Integer sessionType) { new StoodLogsAdapter(context).newSession(sessionType); if (context.getSharedPreferences(Constants.USER_SHARED_PREFERENCES, 0) .getBoolean(Constants.DEVICE_STEP_DETECTOR_ENABLED, false)) { Intent startStepCounterIntent = new Intent(context, StandDtectorTM.class); startStepCounterIntent.setAction(com.heckbot.standdtector.Constants.START_DEVICE_STEP_COUNTER); context.startService(startStepCounterIntent); }//from w w w.j av a 2 s. c o m }
From source file:com.avalond.ad_blocak.vpn.AdVpnService.java
public static void checkStartVpnOnBoot(Context context) { Log.i("BOOT", "Checking whether to start ad buster on boot"); Configuration config = FileHelper.loadCurrentSettings(context); if (config == null || !config.autoStart) { return;/* ww w . j a v a 2s .co m*/ } if (VpnService.prepare(context) != null) { Log.i("BOOT", "VPN preparation not confirmed by user, changing enabled to false"); } Log.i("BOOT", "Starting ad buster from boot"); Intent intent = new Intent(context, AdVpnService.class); intent.putExtra("COMMAND", Command.START.ordinal()); intent.putExtra("NOTIFICATION_INTENT", PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0)); context.startService(intent); }
From source file:nl.sogeti.android.gpstracker.integration.GPSLoggerServiceManager.java
public static void setAutomaticLogging(Context context, boolean atBoot, boolean atDocking, boolean atUnDocking, boolean atPowerConnect, boolean atPowerDisconnect) { Intent intent = createServiceIntent(); intent.putExtra(ExternalConstants.Commands.CONFIG_START_AT_BOOT, atBoot); intent.putExtra(ExternalConstants.Commands.CONFIG_START_AT_DOCK, atDocking); intent.putExtra(ExternalConstants.Commands.CONFIG_STOP_AT_UNDOCK, atUnDocking); intent.putExtra(ExternalConstants.Commands.CONFIG_START_AT_POWER_CONNECT, atPowerConnect); intent.putExtra(ExternalConstants.Commands.CONFIG_STOP_AT_POWER_DISCONNECT, atPowerDisconnect); context.startService(intent); }
From source file:fr.inria.ucn.Helpers.java
/** * Start (schedule) the data collector service. * /* w w w. ja v a 2 s . co m*/ * @param context * @param wl Need wakelock? */ public static void startCollector(Context context, boolean wl) { if (wl) Helpers.acquireLock(context); Intent sintent = new Intent(context, CollectorService.class); sintent.setAction(Constants.ACTION_SCHEDULE); sintent.putExtra(Constants.INTENT_EXTRA_SCHEDULER_START, true); if (wl) sintent.putExtra(Constants.INTENT_EXTRA_RELEASE_WL, true); // request service to release the wl context.startService(sintent); }
From source file:fr.inria.ucn.Helpers.java
/** * Stop (schedule) the data collector service. * /* w w w . j a va 2s . c o m*/ * @param context * @param wl Need wakelock? */ public static void stopCollector(Context context, boolean wl) { if (wl) Helpers.acquireLock(context); Intent sintent = new Intent(context, CollectorService.class); sintent.setAction(Constants.ACTION_SCHEDULE); sintent.putExtra(Constants.INTENT_EXTRA_SCHEDULER_START, false); if (wl) sintent.putExtra(Constants.INTENT_EXTRA_RELEASE_WL, true); // request service to release the wl context.startService(sintent); }