本文整理匯總了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));
}