![](/img/trans.png)
[英]Long running background task from BroadcastReceiver - which class to use?
由於AsyncTask 、 IntentSerrvice和JobIntentService都被棄用了,我應該在 2022 年使用哪個工具或 class go? 我想在設備重啟后重新安排BroadcastReceiver中的警報(因為警報在此過程中丟失)。 該任務很可能需要 < 1 分鍾才能完 ...
[英]Long running background task from BroadcastReceiver - which class to use?
由於AsyncTask 、 IntentSerrvice和JobIntentService都被棄用了,我應該在 2022 年使用哪個工具或 class go? 我想在設備重啟后重新安排BroadcastReceiver中的警報(因為警報在此過程中丟失)。 該任務很可能需要 < 1 分鍾才能完 ...
[英]Long running service to receive push messages from emqx
我想實現一個長時間運行的服務來接收來自emqx服務器的推送消息(即使程序沒有運行)。 如果我使用 android Service 或 JobIntentService,則需要顯示非預期的通知。 如果我使用 WorkManager,可以定義的最小重復間隔為 15 分鍾。 出於某種原因,我們不想使用 F ...
[英]Kotlin: How to call JobIntentService from Fragment?
我正在創建 GPS 跟蹤應用程序。 所以我需要在后台(或前台?)運行這個應用程序。 當我點擊 Fragment (FirstClass) 中的“開始”按鈕時,如何調用 JobIntentService (SecondClass) class? 例如,我查看了這段代碼- 但我仍然不明白如何從片段 c ...
[英]Best way get GPS Location in background for Android API level 30 and higher
我的應用程序根據用戶的位置確定速度限制,並告訴用戶他是否超過了它。 從 Android API 級別 30 及更高級別開始,Google 已將 IntentService 定義為已棄用,並建議使用WorkManager或JobIntentService ,並聲明有必要從Z035489FF8D0927 ...
[英]Show notification every 1 minute Android
我想在用戶打開應用程序時運行一項服務,然后只要每 1 分鍾安裝一次應用程序就讓它運行。 該服務將通過調用 API 來檢查是否有新訂單,如果有,則會顯示通知。 我做了一些研究,發現 JobIntentService 和 Broadcast Reciever 是我需要用來解決我的問題,但我無法將它們放 ...
[英]JobIntentService - onHandleWork is not always called?
我有主屏幕小部件,它有一個簡單的AppWidgetProvider和JobIntentService ,我可以在其中完成所有工作。 問題是 - 它的工作方式是隨機的。 有時會,有時不會 - 最奇怪的是,我可以在日志中看到,在每個小部件更新時, JobIntentService的enqueueWor ...
[英]How to prevent TransactionTooLarge exception while passing data between JobIntentService to activity via Broadcast receiver
登錄頁面后,我正在使用 JobIntentService 從服務器下載數據,並通過 BroadcastReceiver 將數據傳遞給活動。 對於較少量的數據,它可以正常工作,但是當我處理實時數據時,它會給出以下異常: ...
[英]Android JobIntentService as wrapper on another service
這需要一些上下文,請與我裸露... 我已將用於評估 NFC 數據的依賴項遷移到新應用程序。 每當發現 NFC 標簽時,我的應用程序都會生成一個 Activity 來處理該事件。 在這個NfcActivity的onCreate function 中,啟動了一個后台服務(我們稱之為MyNfcHelper ...
[英]When to release the coroutine resources in android service?
我在我的JobIntentService中使用 kotlin 協程,所以在onHandleWork我會啟動我的協程,一旦這個任務結束,我需要通過取消Job來清理資源。 onDestroy在服務啟動后立即調用,因為我在onHandleWork上啟動協程,它不會阻塞當前線程。 完成任務后必須取消協程 ...
[英]IntentService is deprecated, how do I replace it with JobIntentService?
在FetchAddressIntentService實現IntentService之后(在 kotlin 中): 有人建議我如何以一種好的方式將IntentService替換為JobIntentService嗎? IntentService在 Android-R / Android-11 中已棄 ...
[英]sendBroadcast from inside Service which uses Coroutine for network call
我有一個 JobIntentService 應該執行 API 調用並在結果可用后進行廣播。 我正在使用協程使用 Retrofit 進行網絡調用。 但是,如果我在 CoroutineScope 內發送廣播,它不會觸發 BroadcastReceiver 這是我的服務代碼 - 我的服務.kt Serv ...
[英]Can onDestroy() be called without onHandleWork() in JobIntentService?
我正在使用JobIntentService.enqueueWork() 我想知道即使沒有在onHandleWork()調用onHandleWork()也有可能調用onDestroy() 。 基本上,JobIntentService 的生命周期是什么。 onHandleWork()保證在onDe ...
[英]JobIntentService not call OnHandleWork
我已經自定義JobIntentService 和靜態方法enqueueWork 。 我還自定義了 FirebaseMessagingService 的實現。 當我收到來自 FCM 的推送通知時,我會調用我的JobIntentService的enqueueWork 。 但方法OnHandleW ...
[英]When to use JobIntentService vs WorkManager?
谷歌最近棄用了 IntentService: https ://android.googlesource.com/platform/frameworks/base.git/+/6f8b09029932dfd24945202017639754b00acc2e IntentService 的文檔現在 ...
[英]How to integrate any AndroidX SDK in Non AndroidX app
我已將我的 Android 庫項目 (SDK) 遷移到 AndroidX,它正在使用implementation 'androidx.core:core:1.1.0'依賴項。 將此 SDK 集成到非 AndroidX 應用程序后,我的 SDK 崩潰並出現以下異常: 我的 SDK 用戶中很少有人尚 ...
[英]Does not require android.permission.BIND_JOB_SERVICE permission in Android
雖然這已經得到回答。 我試過那些但沒有運氣。 就我而言,我在同一個項目中使用 JobService 和 JobIntentService 來測試和學習東西。 JobService 工作正常,但是當我嘗試 JobIntentService 時,它在我的情況下不起作用,我面臨以下錯誤: 盡管正如其他答 ...
[英]Calling an acitivty method from a JobIntentService
我想在onHandleWork內部的for循環中調用一個非靜態方法。 我該如何實現? ...
[英]How can I access my activity's ViewModel from within a service?
我正在構建一個需要檢測照片中某些對象的應用程序。 我首先將所有要檢查的照片加載並保存到我的房間數據庫中,然后使用 ViewHolder 將其連接到我的視圖。 當用戶單擊一個按鈕時,我希望開始檢測過程,並且我想為此使用 jobIntentService(因為那里可能有數千張照片)。 我的問題是 - ...
[英]Background service issue in oreo and pie
基本上我想在后台發送緯度和經度,它在奧利奧版本下工作正常,但我被困在那個部分。 它工作得很好。 我添加了一個后台 JobIntentService,它在 Oreo 和 pie 背景中運行良好,但是當我在 2 分鍾后鎖定屏幕時,它會禁用或停止向我的服務器發送位置。 ...
[英]FusedLocationProviderClient and Wakelocks
我正在實現一個解決方案,以跟蹤我的應用程序中前台和后台的位置更新,並在位置更新時執行一些任務。 根據https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationPr ...