2016-08-09 18 views
2

由於我的應用程序必須是可用於Android 4.x版本,我不能僅僅依靠的jobscheduler背景活動。 Firebase JobDispatcher與我需要的版本向後兼容,所以我測試了一下。Firebase JobDispatcher是否使用JobScheduler?

我的期望是,它使用谷歌播放服務在Android < 5時和API的jobscheduler 5+時,從Android的電池和存儲優化上this slide看到談話在谷歌I/O 2016

喬布斯,我在使用JobDispatcher和testapp,其自帶的火力地堡JobDispatcher自己的應用程序安排,做的工作。致電adb shell dumpsys jobscheduler時我沒有看到任何活動。當我直接使用JobScheduler時,我可以看到那裏的工作沒有問題。

所以我想我上面鏈接的幻燈片是錯了嗎? 在Android 5+上可以讓JobDispatcher使用JobScheduler嗎?也許用自定義驅動程序?

+1

那麼有希望谷歌提供了一個司機的jobscheduler: https://github.com/firebase/firebase-jobdispatcher-android/issues/32#issuecomment-249266296 – Henning

回答

0

我得到的Android 7.1.1控制檯輸出...不是太少:

adb shell dumpsys jobscheduler | grep x\ active 

在過去的SDK版本dumpsys jobscheduler可能只是無法轉儲什麼是不存在(如開機SDK版本,然後發出命令會顯示,因爲它工作時)。

雖然由於Android 7.0.0沒有爲jobscheduler一個新的命令:

adb shell cmd jobscheduler help 

Job scheduler (jobscheduler) commands: 
    help 
    Print this help text. 
    run [-f | --force] [-u | --user USER_ID] PACKAGE JOB_ID 
    Trigger immediate execution of a specific scheduled job. 
    Options: 
     -f or --force: run the job even if technical constraints such as connectivity are not currently met 
     -u or --user: specify which users job is to be run; the default is the primary or system user 

作業調度和作業調度整整兩個不同的東西;調度員已經爲了向後兼容的驅動程序(因此不能指望操作系統有調度)。

見​​或本answer可能會進一步解釋。

android-job庫也確實不太一樣,一般。

+0

謝謝您的回答。 '我在shell中看不到任何活動',我的意思是我的應用程序。如果沒有一個適當的JobScheduler Driver,JobDispatcher現在很沒用。我自己爲它構建了一個基本的調度程序驅動程序,但我仍然感到失望。 GitHub項目幾乎沒有任何活動,並且承諾的功能[一年後仍然缺失](https://github.com/firebase/firebase-jobdispatcher-android/issues/32)。事後看來,我應該使用Evernote Android-Job庫。 – Henning

相關問題