本文整理了Java中android.app.Service.stopForeground()
方法的一些代码示例,展示了Service.stopForeground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Service.stopForeground()
方法的具体详情如下:
包路径:android.app.Service
类名称:Service
方法名:stopForeground
暂无
代码示例来源:origin: westnordost/StreetComplete
private void hideProgressNotification()
{
service.stopForeground(true);
}
代码示例来源:origin: Genymobile/gnirehtet
public void stop() {
context.stopForeground(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
deleteNotificationChannel();
}
}
代码示例来源:origin: NightscoutFoundation/xDrip
public void stop() {
if (run_service_in_foreground) {
Log.d(TAG, "should be moving out of foreground");
mService.stopForeground(true);
}
}
代码示例来源:origin: jamorham/xDrip-plus
public void stop() {
if (run_service_in_foreground) {
Log.d(TAG, "should be moving out of foreground");
mService.stopForeground(true);
}
}
代码示例来源:origin: gateship-one/odyssey
public void clearNotification() {
if (mNotification != null) {
if (mContext instanceof Service) {
((Service) mContext).stopForeground(true);
mNotificationBuilder.setOngoing(false);
mNotificationManager.cancel(NOTIFICATION_ID);
}
mNotification = null;
mLastTrack = null;
mLastBitmap = null;
mNotificationBuilder = null;
}
}
代码示例来源:origin: NightscoutFoundation/xDrip
protected void stopInForeground() {
// TODO refuse to stop on oreo+ ?
if (service != null) {
service.stopForeground(true);
} else {
UserError.Log.e("FOREGROUND", "Cannot stop foreground as service is null");
}
foregroundStatus();
}
代码示例来源:origin: jamorham/xDrip-plus
protected void stopInForeground() {
// TODO refuse to stop on oreo+ ?
if (service != null) {
service.stopForeground(true);
} else {
UserError.Log.e("FOREGROUND", "Cannot stop foreground as service is null");
}
foregroundStatus();
}
代码示例来源:origin: jamorham/xDrip-plus
protected void stopInForeground() {
// TODO refuse to stop on oreo+ ?
if (service != null) {
service.stopForeground(true);
} else {
UserError.Log.e("FOREGROUND", "Cannot stop foreground as service is null");
}
foregroundStatus();
}
代码示例来源:origin: stephen8341/KeepProcLive
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Service core = sCore;
if (null != intent && null != core) {
Log.i(TAG, "onStartCommand");
try {
core.startForeground(NOTIFICATION_ID, new Notification());
startForeground(NOTIFICATION_ID, new Notification());
core.stopForeground(true);
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
}
return Service.START_NOT_STICKY;
}
}
代码示例来源:origin: y20k/transistor
public static void update(final Service service, Station station, MediaSessionCompat session) {
// session can be null on update - happens when currently playing station was renamed
if (session != null) {
// update mSession
mSession = session;
}
// build notification
mNotification = getNotificationBuilder(service, station).build();
// display updated notification
NotificationManager notificationManager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(PLAYER_SERVICE_NOTIFICATION_ID, mNotification);
if (station.getPlaybackState() == PLAYBACK_STATE_STOPPED) {
// make notification swipe-able
service.stopForeground(false);
}
}
代码示例来源:origin: NightscoutFoundation/xDrip
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if(key.compareTo("run_service_in_foreground") == 0) {
Log.d("FOREGROUND", "run_service_in_foreground changed!");
if (prefs.getBoolean("run_service_in_foreground", false)) {
foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
foregroundServiceStarter.start();
Log.i(TAG, "Moving to foreground");
} else {
service.stopForeground(true);
Log.i(TAG, "Removing from foreground");
}
}
}
};
代码示例来源:origin: jamorham/xDrip-plus
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if(key.compareTo("run_service_in_foreground") == 0) {
Log.d("FOREGROUND", "run_service_in_foreground changed!");
if (prefs.getBoolean("run_service_in_foreground", false)) {
foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service);
foregroundServiceStarter.start();
Log.i(TAG, "Moving to foreground");
} else {
service.stopForeground(true);
Log.i(TAG, "Removing from foreground");
}
}
}
};
代码示例来源:origin: fennifith/Status
} else service.stopForeground(true);
);
} else service.stopForeground(true);
代码示例来源:origin: gateship-one/odyssey
((Service) mContext).startForeground(NOTIFICATION_ID, mNotification);
} else {
((Service) mContext).stopForeground(false);
内容来源于网络,如有侵权,请联系作者删除!