public boolean stop() { return context.stopService(intent); } }
@Override public boolean stopService(Intent name) { return mBase.stopService(name); }
@Override public void unbindByContext(Context context) { Intent i = new Intent(context, SERVICE_CLASS); context.stopService(i); handler = null; }
public static void stop(Context context) { context.stopService(new Intent(context, SyncService.class)); }
/** * Stops the service. * @param context application context * @param forceStop stops the service no matter if some tasks are running * @return true if the service is getting stopped, false otherwise */ public static synchronized boolean stop(final Context context, boolean forceStop) { if (forceStop) { return context.stopService(new Intent(context, UploadService.class)); } return uploadTasksMap.isEmpty() && context.stopService(new Intent(context, UploadService.class)); }
/** * 停止服务. * * @param context the context * @param className the class name * @return true, if successful */ public static boolean stopRunningService(Context context, String className) { Intent intent_service = null; boolean ret = false; try { intent_service = new Intent(context, Class.forName(className)); } catch (Exception e) { e.printStackTrace(); } if (intent_service != null) { ret = context.stopService(intent_service); } return ret; }
public class NetWatcher extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //here, check that the network connection is available. If yes, start your service. If not, stop your service. ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) { if (info.isConnected()) { //start service Intent intent = new Intent(context, MyService.class); context.startService(intent); } else { //stop service Intent intent = new Intent(context, MyService.class); context.stopService(intent); } } } }
@Override public void unbindByContext(final Context context) { if (!bindContexts.contains(context)) { return; } if (FileDownloadLog.NEED_LOG) { FileDownloadLog.d(this, "unbindByContext %s", context); } bindContexts.remove(context); if (bindContexts.isEmpty()) { releaseConnect(false); } Intent i = new Intent(context, serviceClass); context.unbindService(this); context.stopService(i); }
private void stopServices() { if (config.stopServicesOnCrash()) { try { final ActivityManager activityManager = SystemServices.getActivityManager(context); final List<ActivityManager.RunningServiceInfo> runningServices = activityManager.getRunningServices(Integer.MAX_VALUE); final int pid = Process.myPid(); for (ActivityManager.RunningServiceInfo serviceInfo : runningServices) { if (serviceInfo.pid == pid && !LegacySenderService.class.getName().equals(serviceInfo.service.getClassName()) && !JobSenderService.class.getName().equals(serviceInfo.service.getClassName())) { try { final Intent intent = new Intent(); intent.setComponent(serviceInfo.service); context.stopService(intent); } catch (SecurityException e) { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Unable to stop Service " + serviceInfo.service.getClassName() + ". Permission denied"); } } } } catch (SystemServices.ServiceNotReachedException e) { ACRA.log.e(LOG_TAG, "Unable to stop services", e); } } }
runInSeparateProcess(new TestService.Procedure() { @Override public void run(final Context context) { final Intent intent = new Intent(context, TestService.class); assertNotNull("Test service is not properly setup.", context.startService(intent)); assertTrue(context.stopService(intent)); installCondomProcess(context, new CondomOptions().setOutboundJudge(sBlockAllJudge)); withFakeSelfPackageName(new Runnable() { @Override public void run() { assertNull(context.startService(intent)); }}); // Block by outbound judge assertTrue(context.stopService(intent)); }}); // TODO: More cases
/** * Method reserved for system use */ @Override public void unbindService(ServiceConnection conn) { application.getApplicationContext().unbindService(conn); application.getApplicationContext().stopService(serviceIntent); serviceConnected = false; } }
private synchronized void publishFinished(PublishBean bean) { publishQueue.poll(); Logger.w("publishFinished" + publishQueue.size()); // 队列发送完毕了,且当前运行的页面不是发布页面,就停止服务 if (publishQueue.size() == 0) context.stopService(new Intent(context, PublishService.class)); else { postDelayed(new Runnable() { @Override public void run() { onPublish(publishQueue.peek()); } }, 2 * 1000); } }
@Override public boolean stopService(Intent name) { return mBase.stopService(name); }
public void stopService() { context.stopService(new Intent(context, InspeckageService.class)); context.stopService(new Intent(context, LogService.class)); } }
/** * stop background music * * @param mContext */ public static void backgroundMusicStop(Context mContext) { mContext.stopService(new Intent(mContext, BackgroundMusicService.class)); }
/** * stop background music * * @param mContext */ public static void backgroundMusicStop(Context mContext) { mContext.stopService(new Intent(mContext, BackgroundMusicService.class)); }
public void stopService() { context.stopService(new Intent(context, InspeckageService.class)); context.stopService(new Intent(context, LogService.class)); } }
public void stopService() { context.stopService(new Intent(context, InspeckageService.class)); }
private Response stopWS() { mContext.stopService(new Intent(mContext, LogService.class)); return ok("OK"); }
public static void deactivateService(Context context) { context.startService(getServiceIntent(context).setAction(DaedalusVpnService.ACTION_DEACTIVATE)); context.stopService(getServiceIntent(context)); }