Example usage for android.app Service START_NOT_STICKY

List of usage examples for android.app Service START_NOT_STICKY

Introduction

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

Prototype

int START_NOT_STICKY

To view the source code for android.app Service START_NOT_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 ), and there are no new start intents to deliver to it, then take the service out of the started state and don't recreate until a future explicit call to Context#startService Context.startService(Intent) .

Usage

From source file:de.hero.vertretungsplan.CheckForUpdates.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    new HtmlWorkAndNotify(this);
    return Service.START_NOT_STICKY;
}

From source file:org.uab.deic.uabdroid.services.AlarmService.java

@Override
public int onStartCommand(Intent _intent, int _flags, int _startId) {
    mStartId = _startId;//from   ww w. j  a v a2s  .  c  om
    new AlarmAsyncTask().execute();

    return Service.START_NOT_STICKY;
}

From source file:com.adam.aslfms.service.ForegroundHide.java

@Override
public int onStartCommand(Intent i, int flags, int startId) {
    //Bundle extras = i.getExtras();

    Intent targetIntent = new Intent(mCtx, SettingsActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(mCtx, 0, targetIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(mCtx).setContentTitle("")
            .setSmallIcon(R.mipmap.ic_notify).setContentText("").setPriority(NotificationCompat.PRIORITY_MIN)
            .setContentIntent(contentIntent);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
        builder.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher));
    }//from w w w  . j  ava 2s  . c  o  m

    this.startForeground(14619, builder.build());

    this.stopForeground(true);
    return Service.START_NOT_STICKY;
}

From source file:com.github.rutvijkumar.twittfuse.services.OfflinePostedTweetProcessingService.java

public int onStartCommand(Intent intent, int flags, int startId) {
    processOfflineTweets();
    return Service.START_NOT_STICKY;
}

From source file:com.parse.GCMService.java

@Override
public int onStartCommand(final Intent intent, int flags, final int startId) {
    executor.execute(new Runnable() {
        @Override//from  ww  w .  j  av  a 2  s .c o  m
        public void run() {
            try {
                onHandleIntent(intent);
            } finally {
                ServiceUtils.completeWakefulIntent(intent);
                stopParent(startId); // automatically stops service if this is the last outstanding task
            }
        }
    });

    return Service.START_NOT_STICKY;
}

From source file:com.goftagram.telegram.messenger.VideoEncodingService.java

public int onStartCommand(Intent intent, int flags, int startId) {
    path = intent.getStringExtra("path");
    if (path == null) {
        stopSelf();/*from   www.j ava 2 s  . c om*/
        return Service.START_NOT_STICKY;
    }
    FileLog.e("tmessages", "start video service");
    if (builder == null) {
        builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
        builder.setSmallIcon(android.R.drawable.stat_sys_upload);
        builder.setWhen(System.currentTimeMillis());
        builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setTicker(LocaleController.getString("SendingVideo", R.string.SendingVideo));
        builder.setContentText(LocaleController.getString("SendingVideo", R.string.SendingVideo));
    }
    currentProgress = 0;
    builder.setProgress(100, currentProgress, currentProgress == 0);
    startForeground(4, builder.build());
    NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(4, builder.build());
    return Service.START_NOT_STICKY;
}

From source file:org.cafemember.messenger.VideoEncodingService.java

public int onStartCommand(Intent intent, int flags, int startId) {
    path = intent.getStringExtra("path");
    if (path == null) {
        stopSelf();/*from w  ww  .  j a v a  2  s .c  o m*/
        return Service.START_NOT_STICKY;
    }
    FileLog.e("tmessages", "start video service");
    if (builder == null) {
        builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
        builder.setSmallIcon(android.R.drawable.stat_sys_upload);
        builder.setWhen(System.currentTimeMillis());
        builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setTicker(LocaleController.getString("SendingVideo", R.string.SendingVideo));
        builder.setContentText(LocaleController.getString("SendingVideo", R.string.SendingVideo));
    }
    currentProgress = 0;
    builder.setProgress(100, currentProgress, currentProgress == 0);
    startForeground(4, builder.build());
    //        NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(4, builder.build());
    return Service.START_NOT_STICKY;
}

From source file:kr.wdream.storyshop.VideoEncodingService.java

public int onStartCommand(Intent intent, int flags, int startId) {
    path = intent.getStringExtra("path");
    boolean isGif = intent.getBooleanExtra("gif", false);
    if (path == null) {
        stopSelf();/*w ww.j av a  2 s  .  c o  m*/
        return Service.START_NOT_STICKY;
    }
    FileLog.e("tmessages", "start video service");
    if (builder == null) {
        builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
        builder.setSmallIcon(android.R.drawable.stat_sys_upload);
        builder.setWhen(System.currentTimeMillis());
        builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName));
        if (isGif) {
            builder.setTicker(LocaleController.getString("SendingGif", R.string.SendingGif));
            builder.setContentText(LocaleController.getString("SendingGif", R.string.SendingGif));
        } else {
            builder.setTicker(LocaleController.getString("SendingVideo", R.string.SendingVideo));
            builder.setContentText(LocaleController.getString("SendingVideo", R.string.SendingVideo));
        }
    }
    currentProgress = 0;
    builder.setProgress(100, currentProgress, currentProgress == 0);
    startForeground(4, builder.build());
    NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(4, builder.build());
    return Service.START_NOT_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   w  w  w.  j ava 2 s .co m*/

    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.ferdi2005.secondgram.VideoEncodingService.java

public int onStartCommand(Intent intent, int flags, int startId) {
    path = intent.getStringExtra("path");
    boolean isGif = intent.getBooleanExtra("gif", false);
    if (path == null) {
        stopSelf();//from  w  w  w. j a  v a  2s .c  om
        return Service.START_NOT_STICKY;
    }
    FileLog.e("start video service");
    if (builder == null) {
        builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
        builder.setSmallIcon(android.R.drawable.stat_sys_upload);
        builder.setWhen(System.currentTimeMillis());
        builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName));
        if (isGif) {
            builder.setTicker(LocaleController.getString("SendingGif", R.string.SendingGif));
            builder.setContentText(LocaleController.getString("SendingGif", R.string.SendingGif));
        } else {
            builder.setTicker(LocaleController.getString("SendingVideo", R.string.SendingVideo));
            builder.setContentText(LocaleController.getString("SendingVideo", R.string.SendingVideo));
        }
    }
    currentProgress = 0;
    builder.setProgress(100, currentProgress, currentProgress == 0);
    startForeground(4, builder.build());
    NotificationManagerCompat.from(ApplicationLoader.applicationContext).notify(4, builder.build());
    return Service.START_NOT_STICKY;
}