Search in sources :

Example 21 with Service

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();
}
Also used : Service(android.app.Service)

Example 22 with Service

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;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Service(android.app.Service) Intent(android.content.Intent)

Example 23 with Service

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);
}
Also used : Service(android.app.Service) SyncService(com.onesignal.SyncService) Test(org.junit.Test)

Example 24 with 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();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) ScheduledFuture(java.util.concurrent.ScheduledFuture) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) Date(java.util.Date) InvalidFeedException(de.danoeh.antennapod.core.util.InvalidFeedException) IBinder(android.os.IBinder) CompletionService(java.util.concurrent.CompletionService) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) Future(java.util.concurrent.Future) FeedImage(de.danoeh.antennapod.core.feed.FeedImage) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Handler(android.os.Handler) GpodnetSyncService(de.danoeh.antennapod.core.service.GpodnetSyncService) Log(android.util.Log) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) FeedItemEvent(de.danoeh.antennapod.core.event.FeedItemEvent) NotificationManager(android.app.NotificationManager) DownloadError(de.danoeh.antennapod.core.util.DownloadError) Service(android.app.Service) IntentFilter(android.content.IntentFilter) ClientConfig(de.danoeh.antennapod.core.ClientConfig) BlockingQueue(java.util.concurrent.BlockingQueue) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) BroadcastReceiver(android.content.BroadcastReceiver) Executors(java.util.concurrent.Executors) FeedPreferences(de.danoeh.antennapod.core.feed.FeedPreferences) List(java.util.List) ChapterUtils(de.danoeh.antennapod.core.util.ChapterUtils) DownloadEvent(de.danoeh.antennapod.core.event.DownloadEvent) SAXException(org.xml.sax.SAXException) UnsupportedFeedtypeException(de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException) Notification(android.app.Notification) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) R(de.danoeh.antennapod.core.R) FeedHandlerResult(de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult) Context(android.content.Context) EventBus(de.greenrobot.event.EventBus) MediaMetadataRetriever(android.media.MediaMetadataRetriever) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) Callable(java.util.concurrent.Callable) NonNull(android.support.annotation.NonNull) ArrayList(java.util.ArrayList) Binder(android.os.Binder) SuppressLint(android.annotation.SuppressLint) FeedHandler(de.danoeh.antennapod.core.syndication.handler.FeedHandler) Feed(de.danoeh.antennapod.core.feed.Feed) LinkedList(java.util.LinkedList) ExecutorService(java.util.concurrent.ExecutorService) GpodnetEpisodeAction(de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction) URLUtil(android.webkit.URLUtil) TextUtils(android.text.TextUtils) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) FeedItem(de.danoeh.antennapod.core.feed.FeedItem) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) Bitmap(android.graphics.Bitmap) Pair(android.support.v4.util.Pair) NotificationCompat(android.support.v4.app.NotificationCompat) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) Action(de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction.Action) DBReader(de.danoeh.antennapod.core.storage.DBReader) DownloadRequester(de.danoeh.antennapod.core.storage.DownloadRequester) GpodnetPreferences(de.danoeh.antennapod.core.preferences.GpodnetPreferences) Collections(java.util.Collections) DBTasks(de.danoeh.antennapod.core.storage.DBTasks) IntentFilter(android.content.IntentFilter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ArrayList(java.util.ArrayList) Handler(android.os.Handler) FeedHandler(de.danoeh.antennapod.core.syndication.handler.FeedHandler) SuppressLint(android.annotation.SuppressLint)

Aggregations

Service (android.app.Service)24 ServiceInfo (android.content.pm.ServiceInfo)12 Intent (android.content.Intent)8 Handler (android.os.Handler)3 SyncService (com.onesignal.SyncService)3 EventManager (roboguice.event.EventManager)3 Activity (android.app.Activity)2 Application (android.app.Application)2 IntentService (android.app.IntentService)2 Context (android.content.Context)2 Configuration (android.content.res.Configuration)2 IBinder (android.os.IBinder)2 Injector (com.google.inject.Injector)2 Test (org.junit.Test)2 SuppressLint (android.annotation.SuppressLint)1 AlarmManager (android.app.AlarmManager)1 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 SearchManager (android.app.SearchManager)1 BroadcastReceiver (android.content.BroadcastReceiver)1