use of android.app.Service in project DroidPlugin by DroidPluginTeam.
the class ServcesManager method onDestroy.
public void onDestroy() {
for (Service service : mTokenServices.values()) {
service.onDestroy();
}
mTokenServices.clear();
mServiceTaskIds.clear();
mNameService.clear();
QueuedWorkCompat.waitToFinish();
}
use of android.app.Service in project DroidPlugin by DroidPluginTeam.
the class ServcesManager method onStart.
public int onStart(Context context, Intent intent, int flags, int startId) throws Exception {
Intent targetIntent = intent.getParcelableExtra(Env.EXTRA_TARGET_INTENT);
if (targetIntent != null) {
ServiceInfo targetInfo = PluginManager.getInstance().resolveServiceInfo(targetIntent, 0);
if (targetInfo != null) {
Service service = mNameService.get(targetInfo.name);
if (service == null) {
handleCreateServiceOne(context, intent, targetInfo);
}
handleOnStartOne(targetIntent, flags, startId);
}
}
return -1;
}
use of android.app.Service in project OneSignal-Android-SDK by OneSignal.
the class MainOneSignalClassRunner method shouldNotCrashIfOnTaskRemovedIsCalledBeforeInitIsDone.
@Test
public void shouldNotCrashIfOnTaskRemovedIsCalledBeforeInitIsDone() {
Service service = Robolectric.buildService(SyncService.class).create().get();
OneSignalPackagePrivateHelper.SyncService_onTaskRemoved(service);
}
use of android.app.Service in project AntennaPod by AntennaPod.
the class DownloadService method onCreate.
@SuppressLint("NewApi")
@Override
public void onCreate() {
Log.d(TAG, "Service started");
isRunning = true;
handler = new Handler();
reportQueue = Collections.synchronizedList(new ArrayList<>());
downloads = Collections.synchronizedList(new ArrayList<>());
numberOfDownloads = new AtomicInteger(0);
IntentFilter cancelDownloadReceiverFilter = new IntentFilter();
cancelDownloadReceiverFilter.addAction(ACTION_CANCEL_ALL_DOWNLOADS);
cancelDownloadReceiverFilter.addAction(ACTION_CANCEL_DOWNLOAD);
registerReceiver(cancelDownloadReceiver, cancelDownloadReceiverFilter);
syncExecutor = Executors.newSingleThreadExecutor(r -> {
Thread t = new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);
return t;
});
Log.d(TAG, "parallel downloads: " + UserPreferences.getParallelDownloads());
downloadExecutor = new ExecutorCompletionService<>(Executors.newFixedThreadPool(UserPreferences.getParallelDownloads(), r -> {
Thread t = new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);
return t;
}));
schedExecutor = new ScheduledThreadPoolExecutor(SCHED_EX_POOL_SIZE, r -> {
Thread t = new Thread(r);
t.setPriority(Thread.MIN_PRIORITY);
return t;
}, (r, executor) -> Log.w(TAG, "SchedEx rejected submission of new task"));
downloadCompletionThread.start();
feedSyncThread = new FeedSyncThread();
feedSyncThread.start();
setupNotificationBuilders();
requester = DownloadRequester.getInstance();
}
Aggregations