本文整理匯總了Java中android.support.v4.content.ContextCompat.startForegroundService方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextCompat.startForegroundService方法的具體用法?Java ContextCompat.startForegroundService怎麽用?Java ContextCompat.startForegroundService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.content.ContextCompat
的用法示例。
在下文中一共展示了ContextCompat.startForegroundService方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doBind
import android.support.v4.content.ContextCompat; //導入方法依賴的package包/類
/**
* Bind Activity to the service
*/
private void doBind() {
Log.i(TAG, "Binding service...");
final Intent serviceIntent = SteamService.createIntent(this);
ContextCompat.startForegroundService(this, serviceIntent);
bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE);
serviceBound = true;
}
示例2: startCarService
import android.support.v4.content.ContextCompat; //導入方法依賴的package包/類
private void startCarService() {
Intent startIntent = new Intent(mApplication, CarService.class);
startIntent.setAction(CarService.ACTION_START_CAR_SERVICE);
ContextCompat.startForegroundService(mApplication, startIntent);
}
示例3: moveServiceToStartedState
import android.support.v4.content.ContextCompat; //導入方法依賴的package包/類
private void moveServiceToStartedState(PlaybackStateCompat state) {
Notification notification =
mMediaNotificationManager.getNotification(
mPlayback.getCurrentMedia(), state, getSessionToken());
if (!mServiceInStartedState) {
ContextCompat.startForegroundService(
MusicService.this,
new Intent(MusicService.this, MusicService.class));
mServiceInStartedState = true;
}
startForeground(MediaNotificationManager.NOTIFICATION_ID, notification);
}
示例4: stopCarService
import android.support.v4.content.ContextCompat; //導入方法依賴的package包/類
private void stopCarService() {
Intent stopIntent = new Intent(mApplication, CarService.class);
stopIntent.setAction(CarService.ACTION_STOP_CAR_SERVICE);
ContextCompat.startForegroundService(mApplication, stopIntent);
}
示例5: startUpgrade
import android.support.v4.content.ContextCompat; //導入方法依賴的package包/類
public static void startUpgrade(final Context context) {
ContextCompat.startForegroundService(context, new Intent(context, UpgradeWalletService.class));
}
示例6: startMaybeShowNotification
import android.support.v4.content.ContextCompat; //導入方法依賴的package包/類
public static void startMaybeShowNotification(final Context context) {
ContextCompat.startForegroundService(context, new Intent(context, InactivityNotificationService.class));
}