當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。