Example usage for android.app Service START_STICKY

List of usage examples for android.app Service START_STICKY

Introduction

In this page you can find the example usage for android.app Service START_STICKY.

Prototype

int START_STICKY

To view the source code for android.app Service START_STICKY.

Click Source Link

Document

Constant to return from #onStartCommand : if this service's process is killed while it is started (after returning from #onStartCommand ), then leave it in the started state but don't retain this delivered intent.

Usage

From source file:disono.webmons.com.clean_architecture.presentation.ui.activities.communication.voice.SIPService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i(TAG, "onStartCommand");
    return Service.START_STICKY;
}

From source file:com.example.android.elizachat.ResponderService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (null == intent || null == intent.getAction()) {
        return Service.START_STICKY;
    }// w  ww  . j a va  2  s.com
    String action = intent.getAction();
    if (action.equals(ACTION_RESPONSE)) {
        Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent);
        CharSequence replyMessage = "";
        if (remoteInputResults != null) {
            replyMessage = remoteInputResults.getCharSequence(EXTRA_REPLY);
        }
        processIncoming(replyMessage.toString());
    } else if (action.equals(MainActivity.ACTION_GET_CONVERSATION)) {
        broadcastMessage(mCompleteConversation.toString());
    }
    return Service.START_STICKY;
}

From source file:scionoftech.socketservice.Socket.SocketService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    runSocket();//from   ww  w .  j av  a2s  .  c om
    Log.d("Start Service", "Started from Service");

    //restart Service when it killed
    return Service.START_STICKY;
}

From source file:com.hqas.ridetracker.TrackerService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    PebbleKit.registerPebbleConnectedReceiver(this, pebbleConnectedReceiver);
    PebbleKit.registerPebbleDisconnectedReceiver(this, pebbleDisconnectedReceiver);
    PebbleKit.registerReceivedAckHandler(this, pebbleAckReceiver);
    PebbleKit.registerReceivedNackHandler(this, pebbleNackReceiver);
    PebbleKit.registerReceivedDataHandler(this, pebbleDataReceiver);

    return Service.START_STICKY;
}

From source file:eu.alefzero.owncloud.files.services.InstantUploadService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent == null || !intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_DISPLAY_NAME)
            || !intent.hasExtra(KEY_FILE_PATH) || !intent.hasExtra(KEY_FILE_SIZE)
            || !intent.hasExtra(KEY_MIME_TYPE)) {
        Log.w(TAG, "Not all required information was provided, abording");
        return Service.START_NOT_STICKY;
    }/*from   ww  w  .ja  v a2  s. c om*/

    if (mUploaderRunnable == null) {
        mUploaderRunnable = new UploaderRunnable();
    }

    String filename = intent.getStringExtra(KEY_DISPLAY_NAME);
    String filepath = intent.getStringExtra(KEY_FILE_PATH);
    String mimetype = intent.getStringExtra(KEY_MIME_TYPE);
    Account account = intent.getParcelableExtra(KEY_ACCOUNT);
    long filesize = intent.getLongExtra(KEY_FILE_SIZE, -1);

    mUploaderRunnable.addElementToQueue(filename, filepath, mimetype, filesize, account);

    // starting new thread for new download doesnt seems like a good idea
    // maybe some thread pool or single background thread would be better
    Log.d(TAG, "Starting instant upload thread");
    new Thread(mUploaderRunnable).start();

    return Service.START_STICKY;
}

From source file:com.piggate.samples.PiggateLoginService.Service_Notify.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return Service.START_STICKY;
}

From source file:org.jraf.android.bikey.app.collect.LogCollectorService.java

@Override
public int onStartCommand(final Intent intent, int flags, int startId) {
    Log.d("intent=" + StringUtil.toString(intent));
    if (intent == null)
        return Service.START_STICKY;
    String action = intent.getAction();
    if (ACTION_START_COLLECTING.equals(action)) {
        startCollecting(intent.getData());
    } else if (ACTION_STOP_COLLECTING.equals(action)) {
        stopCollecting(intent.getData());
    }/*from   ww w . j  av  a2 s  .  c  om*/
    return Service.START_STICKY;
}

From source file:com.readystatesoftware.ghostlog.LogService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    sIsRunning = true;/*from  w  w  w  .j  av a  2  s . co m*/
    createSystemWindow();
    showNotification();
    startLogReader();
    if (mAutoFilter) {
        startProcessMonitor();
    }
    return Service.START_STICKY;
}

From source file:samples.piggate.com.piggateCompleteExample.Service_Notify.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    logout = false;
    return Service.START_STICKY;
}

From source file:com.cn21.speedtest.service.LogService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    sIsRunning = true;/*from  w w  w  . j a  v  a2s  .  c  o  m*/
    createSystemWindow();//??
    if (mAppFilter) {
        startAppfilter();//?apppid?
    }
    startLogReader();//?
    if (mSavelog) {
        createSavelogdir();
    }
    return Service.START_STICKY;
}