本文整理汇总了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;
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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) {}
});
}
}
示例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));
}
}
示例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;
}
示例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);
}
示例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));
}
示例11: stop
import android.content.Context; //导入方法依赖的package包/类
public static void stop(Context context) {
context.stopService(new Intent(context, SyncService.class));
}
示例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);
}
示例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));
}
示例14: onDisabled
import android.content.Context; //导入方法依赖的package包/类
@Override
public void onDisabled(Context context) {
super.onDisabled(context);
context.stopService(new Intent(context,AppWidgetService.class));
}
示例15: stop
import android.content.Context; //导入方法依赖的package包/类
public static void stop(Context context) {
context.stopService(new Intent(context, IRCService.class));
}