android.app.Service.stopSelf()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中android.app.Service.stopSelf()方法的一些代码示例,展示了Service.stopSelf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Service.stopSelf()方法的具体详情如下:
包路径:android.app.Service
类名称:Service
方法名:stopSelf

Service.stopSelf介绍

暂无

代码示例

代码示例来源:origin: gzu-liyujiang/AndroidPicker

/**
 * 当内存不足时,需要清除已打开的Activity及Service
 *
 * @see android.app.Application#onLowMemory()
 */
public void clearActivitiesAndServices() {
  for (Activity activity : activities) {
    if (!activity.isFinishing()) {
      activity.finish();
    }
  }
  for (Service service : services) {
    service.stopSelf();
  }
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

@Override
public boolean onException(Object obj, Throwable throwable) {
  try {
    if (obj instanceof Activity) {
      ((Activity) obj).finish();
    } else if (obj instanceof Service) {
      ((Service) obj).stopSelf();
    }
} catch (Exception e1) {
  //
}
  return real.onException(obj, throwable);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

for (Service s :list) {
  if (s.getClass().getClassLoader() == plugin.pluginClassLoader) {
    s.stopSelf();

代码示例来源:origin: xbmc/Kore

/**
 * Processes the next item on the sync list, or cleans up if it is finished.
 */
private void nextSync() {
  if (syncItemIterator.hasNext()) {
    partialStartTime = System.currentTimeMillis();
    currentSyncItem = syncItemIterator.next();
    currentSyncItem.sync(this, hostConnection, callbackHandler, contentResolver);
  } else {
    LogUtils.LOGD(TAG, "Sync finished for all items. Total time: " +
              (System.currentTimeMillis() - startTime));
    // No more syncs, cleanup.
    // No need to disconnect, as this is HTTP
    //hostConnection.disconnect();
    if (listener != null) {
      listener.onSyncFinished(this);
    }
    syncService.stopSelf(serviceStartId);
  }
}

代码示例来源:origin: iqiyi/Neptune

/**
   * 尝试执行Service的onDestroy方法
   */
  public void tryToDestroyService() {
    if (mCurrentService != null && shouldDestroy()) {
      try {
        mCurrentService.onDestroy();
        mState = PLUGIN_SERVICE_DESTROYED;
      } catch (Exception e) {
        ErrorUtil.throwErrorIfNeed(e);
      }
      // remove service record.
      PServiceSupervisor.removeServiceByIdentity(getIdentify(mPkgName, mServiceClassName));
      if (PServiceSupervisor.getAliveServices().size() == 0 && mParentService != null) {
        mParentService.stopSelf();
      }
    }
  }
}

代码示例来源:origin: iqiyi/Neptune

service.stopSelf();

相关文章