当前位置: 首页>>代码示例>>Java>>正文


Java ContextCompat.startForegroundService方法代码示例

本文整理汇总了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;
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:11,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:leinardi,项目名称:androidthings-kuman-sm9,代码行数:6,代码来源:MainActivity.java

示例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);
}
 
开发者ID:nazmulidris,项目名称:mediasession-mediaplayer,代码行数:15,代码来源:MusicService.java

示例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);
}
 
开发者ID:leinardi,项目名称:androidthings-kuman-sm9,代码行数:6,代码来源:MainActivity.java

示例5: startUpgrade

import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public static void startUpgrade(final Context context) {
    ContextCompat.startForegroundService(context, new Intent(context, UpgradeWalletService.class));
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:UpgradeWalletService.java

示例6: startMaybeShowNotification

import android.support.v4.content.ContextCompat; //导入方法依赖的package包/类
public static void startMaybeShowNotification(final Context context) {
    ContextCompat.startForegroundService(context, new Intent(context, InactivityNotificationService.class));
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:InactivityNotificationService.java


注:本文中的android.support.v4.content.ContextCompat.startForegroundService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。