当前位置: 首页>>代码示例>>Java>>正文


Java Context.stopService方法代码示例

本文整理汇总了Java中android.content.Context.stopService方法的典型用法代码示例。如果您正苦于以下问题:Java Context.stopService方法的具体用法?Java Context.stopService怎么用?Java Context.stopService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Context的用法示例。


在下文中一共展示了Context.stopService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

import android.content.Context; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
    switch (tm.getCallState()) {
        case TelephonyManager.CALL_STATE_RINGING:
            context.startService(new Intent(context, RecordAudioService.class));
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:

            break;
        case TelephonyManager.CALL_STATE_IDLE:
            context.stopService(new Intent(context, RecordAudioService.class));
            break;
    }
}
 
开发者ID:NaOHAndroid,项目名称:Logistics-guard,代码行数:16,代码来源:PhoneStatReceiver.java

示例2: unbindByContext

import android.content.Context; //导入方法依赖的package包/类
@Override
public void unbindByContext(final Context context) {
    if (!BIND_CONTEXTS.contains(context)) {
        return;
    }

    if (FileDownloadLog.NEED_LOG) {
        FileDownloadLog.d(this, "unbindByContext %s", context);
    }

    BIND_CONTEXTS.remove(context);


    if (BIND_CONTEXTS.isEmpty()) {
        releaseConnect(false);
    }

    Intent i = new Intent(context, serviceClass);
    context.unbindService(this);
    context.stopService(i);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:BaseFileServiceUIGuard.java

示例3: stopService

import android.content.Context; //导入方法依赖的package包/类
public void stopService(Context context)
{
	try
	{
		if(isRunning(context) == true)
		{
			Boolean recordServiceStopped = context.stopService(new Intent(context, RecordService.class));
			
			if(recordServiceStopped == false)
			{
				int stopRetry = 10;
				
				while((recordServiceStopped == false) && (stopRetry >= 0))
				{
					recordServiceStopped = context.stopService(new Intent(context, RecordService.class));
					stopRetry = stopRetry - 1;
				}
			}
		}
	}
	catch (Exception e)
	{
		Log.e("RecordServiceManager", "stopService : " + context.getString(R.string.log_record_service_manager_error_stop) + " : " + e);
		databaseManager.insertLog(context, "" + context.getString(R.string.log_record_service_manager_error_stop), new Date().getTime(), 1, false);
	}
}
 
开发者ID:vassela,项目名称:AC2RD,代码行数:27,代码来源:RecordServiceManager.java

示例4: onUpdate

import android.content.Context; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] ids) {
       if(Build.VERSION.SDK_INT>=21) {
           context.stopService(new Intent(context, NotificationListener.class));
           context.startService(new Intent(context, NotificationListener.class));
       }else{
           context.stopService(new Intent(context, NotificationListenerKK.class));
           context.startService(new Intent(context, NotificationListenerKK.class));
       }
		for (int appWidgetID: ids) {
			updateAppWidget(context, appWidgetManager, appWidgetID);
		}
}
 
开发者ID:jathak,项目名称:musicwidget,代码行数:14,代码来源:StandardWidget.java

示例5: stopBackgroundServiceIfRunning

import android.content.Context; //导入方法依赖的package包/类
public static synchronized void stopBackgroundServiceIfRunning(Context context) {
    boolean alreadyRunning = ServiceHelper.checkIfServiceIsRunning(context, LogcatRecordingService.class);

    log.d("Is CatlogService running: %s", alreadyRunning);

    if (alreadyRunning) {
        Intent intent = new Intent(context, LogcatRecordingService.class);
        context.stopService(intent);
    }

}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:12,代码来源:ServiceHelper.java

示例6: exitSobotChat

import android.content.Context; //导入方法依赖的package包/类
/**
 * 退出客服,用于用户退出登录时调用
 * @param context 上下文对象
    */
public static void exitSobotChat(final Context context){
	if (context == null){
		return;
	}
	disSobotChannel(context);
	context.stopService(new Intent(context, SobotSessionServer.class));

	String cid = SharedPreferencesUtil.getStringData(context,Const.SOBOT_CID,"");
	String uid = SharedPreferencesUtil.getStringData(context,Const.SOBOT_UID,"");
	SharedPreferencesUtil.removeKey(context,Const.SOBOT_WSLINKBAK);
	SharedPreferencesUtil.removeKey(context,Const.SOBOT_WSLINKDEFAULT);
	SharedPreferencesUtil.removeKey(context,Const.SOBOT_UID);
	SharedPreferencesUtil.removeKey(context,Const.SOBOT_CID);
	SharedPreferencesUtil.removeKey(context,Const.SOBOT_PUID);
	SharedPreferencesUtil.removeKey(context,Const.SOBOT_APPKEY);

	if (!TextUtils.isEmpty(cid) && !TextUtils.isEmpty(uid)){
		ZhiChiApi zhiChiApi = SobotMsgManager.getInstance(context).getZhiChiApi();
		zhiChiApi.out(cid, uid,	new StringResultCallBack<CommonModel>() {
			@Override
			public void onSuccess(CommonModel result) {
				LogUtils.i("下线成功");
			}

			@Override
			public void onFailure(Exception e, String des) {}
		});
	}
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:34,代码来源:SobotApi.java

示例7: setServiceEnable

import android.content.Context; //导入方法依赖的package包/类
/**
 * Set XMPush sdk enable
 * @param enable enable
 * @param context context param
 */
public static void setServiceEnable (boolean enable, Context context) {
    if (enable && isAppMainProc(context)) {
        MiPushClient.registerPush(wrapContext(context), APP_ID, APP_KEY);
    } else {
        MiPushClient.unregisterPush(wrapContext(context));
        // Force stop and disable services.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
            scheduler.cancelAll();
        }
        context.stopService(new Intent(context, XMPushService.class));
    }
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:19,代码来源:PushController.java

示例8: unbindByContext

import android.content.Context; //导入方法依赖的package包/类
@Override
public void unbindByContext(Context context) {
    Intent i = new Intent(context, SERVICE_CLASS);
    context.stopService(i);
    handler = null;
}
 
开发者ID:yannanzheng,项目名称:FileDownloader-master,代码行数:7,代码来源:FileDownloadServiceSharedTransmit.java

示例9: onReceive

import android.content.Context; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    Intent shutdown = new Intent(context, MockWalkerService.class);
    context.stopService(shutdown);
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:6,代码来源:ShutdownReceiver.java

示例10: onReceive

import android.content.Context; //导入方法依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
    Prefs.saveBoolean("data_sharing", false, context);
    context.stopService(new Intent(context, Monitor.class));
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:6,代码来源:Monitor.java

示例11: stop

import android.content.Context; //导入方法依赖的package包/类
public static void stop(Context context) {
    context.stopService(new Intent(context, SyncService.class));
}
 
开发者ID:n1rocket,项目名称:eggs-android,代码行数:4,代码来源:SyncService.java

示例12: stopTakingPhoto

import android.content.Context; //导入方法依赖的package包/类
public static void stopTakingPhoto(Context ctx, Callback callback) {
    if (mCallback == callback) mCallback = null;
    Intent intent = new Intent(ctx, PSCameraBgService.class);
    ctx.stopService(intent);
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:6,代码来源:PSCameraBgService.java

示例13: stop

import android.content.Context; //导入方法依赖的package包/类
public static void stop(Context mContext) {
    g.a();
    g.b();
    g.a(false);
    mContext.stopService(new Intent(mContext, SoundInkService.class));
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:7,代码来源:SoundInkInterface.java

示例14: onDisabled

import android.content.Context; //导入方法依赖的package包/类
@Override
public void onDisabled(Context context) {
    super.onDisabled(context);
    context.stopService(new Intent(context,AppWidgetService.class));
}
 
开发者ID:BlueLeer,项目名称:XiaoTianQi,代码行数:6,代码来源:MyAppWidgetProvider.java

示例15: stop

import android.content.Context; //导入方法依赖的package包/类
public static void stop(Context context) {
    context.stopService(new Intent(context, IRCService.class));
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:4,代码来源:IRCService.java


注:本文中的android.content.Context.stopService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。