本文整理匯總了Java中android.support.v4.app.ServiceCompat類的典型用法代碼示例。如果您正苦於以下問題:Java ServiceCompat類的具體用法?Java ServiceCompat怎麽用?Java ServiceCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServiceCompat類屬於android.support.v4.app包,在下文中一共展示了ServiceCompat類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setForeground
import android.support.v4.app.ServiceCompat; //導入依賴的package包/類
private void setForeground() {
boolean enable = Preferences.getForegroundServiceEnabled(this);
if (enable) {
startForeground(NOTIFICATION_ID_FOREGROUND,
MessagingNotification.buildForegroundNotification(this));
}
else {
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE);
}
}
示例2: onStartCommand
import android.support.v4.app.ServiceCompat; //導入依賴的package包/類
public int onStartCommand(Intent intent, int flags, int startId) {
// Tell any local interested parties about the start.
mLocalBroadcastManager.sendBroadcast(new Intent(ACTION_STARTED));
// Prepare to do update reports.
mHandler.removeMessages(MSG_UPDATE);
Message msg = mHandler.obtainMessage(MSG_UPDATE);
mHandler.sendMessageDelayed(msg, 1000);
return ServiceCompat.START_STICKY;
}