Java Code Examples for android.support.v4.content.ContextCompat.startForegroundService()

The following are Jave code examples for showing how to use startForegroundService() of the android.support.v4.content.ContextCompat class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: UpdogFarmer   File: BaseActivity.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 2
Project: androidthings-kuman-sm9   File: MainActivity.java   Source Code and License Vote up 5 votes
private void startCarService() {
    Intent startIntent = new Intent(mApplication, CarService.class);
    startIntent.setAction(CarService.ACTION_START_CAR_SERVICE);
    ContextCompat.startForegroundService(mApplication, startIntent);
}
 
Example 3
Project: mediasession-mediaplayer   File: MusicService.java   Source Code and License Vote up 5 votes
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);
}
 
Example 4
Project: PlayAndroid   File: MusicService.java   Source Code and License Vote up 5 votes
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);
}
 
Example 5
Project: androidthings-kuman-sm9   File: MainActivity.java   Source Code and License Vote up 4 votes
private void stopCarService() {
    Intent stopIntent = new Intent(mApplication, CarService.class);
    stopIntent.setAction(CarService.ACTION_STOP_CAR_SERVICE);
    ContextCompat.startForegroundService(mApplication, stopIntent);
}
 
Example 6
Project: okwallet   File: UpgradeWalletService.java   Source Code and License Vote up 4 votes
public static void startUpgrade(final Context context) {
    ContextCompat.startForegroundService(context, new Intent(context, UpgradeWalletService.class));
}
 
Example 7
Project: okwallet   File: InactivityNotificationService.java   Source Code and License Vote up 4 votes
public static void startMaybeShowNotification(final Context context) {
    ContextCompat.startForegroundService(context, new Intent(context, InactivityNotificationService.class));
}