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