List of usage examples for android.content Context stopService
public abstract boolean stopService(Intent service);
From source file:se.oort.clockify.timer.TimerReceiver.java
private void stopRingtoneIfNoTimesup(final Context context) { if (Timers.findExpiredTimer(mTimers) == null) { // Stop ringtone Log.d(LOG_TAG, "stopping ringtone"); Intent si = new Intent(); si.setClass(context, TimerRingService.class); context.stopService(si); }/* w w w . j ava 2 s . co m*/ }
From source file:com.rareventure.gps2.GTG.java
public static void notifyCollectDataServiceOfUpdate(Context context) { if (prefs.isCollectData) ContextCompat.startForegroundService(context, new Intent(context, GpsTrailerService.class)); else//from w w w . ja va 2s .c o m context.stopService(new Intent(context, GpsTrailerService.class)); }
From source file:com.android.deskclock.timer.TimerReceiver.java
private void stopRingtoneIfNoTimesup(final Context context) { if (Timers.findExpiredTimer(mTimers) == null) { // Stop ringtone Log.d(TAG, "stopping ringtone"); Intent si = new Intent(); si.setClass(context, TimerRingService.class); context.stopService(si); }/* ww w.j a va 2 s .co m*/ }
From source file:com.yacorso.nowaste.views.activities.DrawerActivity.java
/** * Enable every day local notification/*w ww . ja va2 s. c om*/ */ private void enableNotificationReceiver() { Context context = getApplicationContext(); ComponentName receiver = new ComponentName(context, BootCompletedReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Intent serviceIntent = new Intent(context, NotificationService.class); context.stopService(serviceIntent); AlarmReceiver alarmReceiver = new AlarmReceiver(); alarmReceiver.setAlarm(context); }
From source file:com.mattprecious.prioritysms.receiver.AlarmReceiver.java
private void handleIntent(Context context, Intent intent) { if (!intent.hasExtra(Intents.EXTRA_PROFILE)) { missingExtra(Intents.EXTRA_PROFILE); }// w ww .ja v a 2 s. c o m BaseProfile profile = intent.getParcelableExtra(Intents.EXTRA_PROFILE); if (Intents.ALARM_KILLED.equals(intent.getAction())) { boolean replaced = intent.getBooleanExtra(Intents.ALARM_REPLACED, false); if (!replaced) { // TODO: throw a notification saying it was auto-killed NotificationManager nm = getNotificationManager(context); nm.cancel(profile.getId()); // should be caught in the activity, but you can never have too // many stopServices! context.stopService(new Intent(Intents.ACTION_ALERT)); } return; } else if (!Intents.ACTION_ALERT.equals(intent.getAction())) { // Unknown intent, bail. return; } if (!intent.hasExtra(Intents.EXTRA_NUMBER)) { missingExtra(Intents.EXTRA_NUMBER); } else if (profile instanceof SmsProfile) { if (!intent.hasExtra(Intents.EXTRA_MESSAGE)) { missingExtra(Intents.EXTRA_MESSAGE); } } String number = intent.getStringExtra(Intents.EXTRA_NUMBER); String message = intent.getStringExtra(Intents.EXTRA_MESSAGE); Log.v(TAG, "Received alarm set for id=" + profile.getId()); if (profile.getActionType() == ActionType.ALARM) { doAlarm(context, profile, number, message); } else { doNotify(context, profile); } }
From source file:com.google.android.libraries.cast.companionlibrary.cast.BaseCastManager.java
protected void stopReconnectionService() { if (!isFeatureEnabled(CastConfiguration.FEATURE_WIFI_RECONNECT)) { return;//from ww w. j av a2 s.c o m } LOGD(TAG, "stopReconnectionService()"); Context applicationContext = mContext.getApplicationContext(); Intent service = new Intent(applicationContext, ReconnectionService.class); service.setPackage(applicationContext.getPackageName()); applicationContext.stopService(service); }
From source file:com.aware.Aware.java
/** * Stops a plugin. Expects the package name of the plugin. * @param context// ww w . java 2 s .c o m * @param package_name */ public static void stopPlugin(Context context, String package_name) { Cursor is_installed = context.getContentResolver().query(Aware_Plugins.CONTENT_URI, null, Aware_Plugins.PLUGIN_PACKAGE_NAME + " LIKE '" + package_name + "'", null, null); if (is_installed != null && is_installed.moveToFirst()) { //it's installed, stop it! Intent plugin = new Intent(); plugin.setClassName(package_name, package_name + ".Plugin"); context.stopService(plugin); if (Aware.DEBUG) Log.d(TAG, package_name + " stopped..."); ContentValues rowData = new ContentValues(); rowData.put(Aware_Plugins.PLUGIN_STATUS, Aware_Plugin.STATUS_PLUGIN_OFF); context.getContentResolver().update(Aware_Plugins.CONTENT_URI, rowData, Aware_Plugins.PLUGIN_PACKAGE_NAME + " LIKE '" + package_name + "'", null); } if (is_installed != null && !is_installed.isClosed()) is_installed.close(); }
From source file:com.google.sample.castcompanionlibrary.cast.BaseCastManager.java
protected void stopReconnectionService() { if (!isFeatureEnabled(FEATURE_WIFI_RECONNECT)) { return;//from ww w . ja va 2s . c om } LOGD(TAG, "stopReconnectionService()"); Context applicationContext = mContext.getApplicationContext(); Intent service = new Intent(applicationContext, ReconnectionService.class); service.setPackage(applicationContext.getPackageName()); applicationContext.stopService(service); }
From source file:org.kontalk.service.msgcenter.MessageCenterService.java
public static void stop(Context context) { Log.d(TAG, "shutting down message center"); context.stopService(new Intent(context, MessageCenterService.class)); }
From source file:com.andrew.apollo.MusicPlaybackService.java
public static void stopService(Context context) { LOG.info("stopService() <static>"); Intent i = new Intent(); i.setClass(context, MusicPlaybackService.class); context.stopService(i); }