Back to project page Android-MyStarterApp.
The source code is released under:
Apache License
If you think the Android project Android-MyStarterApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package co.kaush.mystarterapp.app.services; /*from ww w . jav a 2 s.c o m*/ import android.content.Intent; import co.kaush.mystarterapp.app.network.ScopedBus; public abstract class QueueClearableIntentService extends BaseIntentService { private final ScopedBus mScopedBus = new ScopedBus(); private boolean mServiceAlreadyRunningInBg = false; public QueueClearableIntentService(String name) { super(name); } @Override public void onCreate() { super.onCreate(); getBus().register(this); } @Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); if (!mServiceAlreadyRunningInBg) { mServiceAlreadyRunningInBg = true; } else { if (!intent.getBooleanExtra("isQueued", false)) { clearQueue(); } } return START_NOT_STICKY; } @Override public void onDestroy() { super.onDestroy(); getBus().unregister(this); } public ScopedBus getBus() { return mScopedBus; } }