當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。