Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WorkManager

takahirom
May 22, 2018
2.6k

 WorkManager

takahirom

May 22, 2018
Tweet

Transcript

  1. 8PSL.BOBHFS
    UBLBIJSPN

    View full-size slide

  2. 荈ⴓחאְג
    ˖ UBLBIJSPN !OFX@SVOOBCMF

    ˖ 劤せכ嬁「䃨峔 ׭׿ׄױ׋ַמ׹

    ˖ "OESPJEָ㥨ֹדׅկ
    ˖ "CFNB57ך"OESPJE،فٔ׾⡲׏גְתׅկ
    ˖ ջ(PPHMF*0ًٌ끅ְ׋הֿ׹ռהְֲ
    2JJUB׾剅ֹת׃׋

    View full-size slide

  3. 8PSL.BOBHFSהכ
    "OESPJE+FUQBDL"SDIJUFDUVSFך⚥ךא
    (PPHMF*0ד涪邌
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

    View full-size slide

  4. ˑ8PSL.BOBHFSJTPVSTPMVUJPO
    GPSEFGFSSBCMFHVBSBOUFFE
    FYFDVUJPO˒
    ⳿ⰩIUUQTZPVUVCFQ&S5Z2Q"

    View full-size slide

  5. %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ⳿ⰩIUUQTZPVUVCFQ&S5Z2Q"

    View full-size slide

  6. %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ˖ خ؎٦زך鷏⥋
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ⳿ⰩIUUQTZPVUVCFQ&S5Z2Q"

    View full-size slide

  7. %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ˖ خ؎٦زך鷏⥋
    ˖ ؚٗ鷏⥋
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ⳿ⰩIUUQTZPVUVCFQ&S5Z2Q"

    View full-size slide

  8. %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ˖ خ؎٦زך鷏⥋
    ˖ ؚٗ鷏⥋
    ˖ ر٦ةず劍
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ⳿ⰩIUUQTZPVUVCFQ&S5Z2Q"

    View full-size slide

  9. %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ˖ خ؎٦زך鷏⥋
    ˖ ؚٗ鷏⥋
    ˖ ر٦ةず劍
    ˖ ًر؍،ؿ؋؎ٕך؟٦غ٦פך،حفٗ٦س
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ⳿ⰩIUUQTZPVUVCFQ&S5Z2Q"

    View full-size slide

  10. ˖ غحؙؚٓؐٝسדװ׷ץֹֿהכ׋ֻׁ׿֮׷
    ˖ ؚٗ鷏⥋ծ،حفٗ٦سծر٦ةず劍ծر٦ة׾Ⳣ椚ׅ׷
    ˖ ׋ֻׁ׿غحؙؚٓؐٝسד㹋遤ׅ׷倯岀ָ֮׷
    ˖ 5ISFBE &YFDVUPS 4FSWJDF "TZOD5BTLזו ⦐ּ׵ְ֮
    ׷

    ˖ "OESPJEךغحذٔ٦剑黝⻉ך堣腉׮׋ֻׁ׿֮׷
    ˖ %P[FNPEF "QQTUBOECZ -JNJUFEJNQMJDJUCSPBEDBTUT
    3FMFBTFDBDIFEXBLFMPDLT 1ד涪邌ׁ׸׋׮ך׾ろ׭׷
    הծ֮ה⦐ּ׵ְ֮׷

    %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ך⡦ָ㉏겗ַ

    View full-size slide

  11. ˖ ة؎ىָؚٝ䖓חז׏ג׮״ֻծ⹛⡲ׅ׷ֿהָ⥂鏾׃׋ְ㜥
    さ׋ֻׁ׿ך鍑寸倯岀ָ֮׷կ
    ˖ +PC4DIFEVMFS 'JSFCBTF+PC%JTQBUDIFS "MBSN.BOBHFS
    #SPBEDBTU3FDFJWFST
    ˖ ⟃♴ך״ֲז鍑寸ٗآحؙ׾荈ⴓד剅ְגծ׋ֻׁ׿ךֿה׾
    罋䣁׃זָ׵׋ֻׁ׿ך"1*ךㄎן⳿׃׾剅ֻ䗳銲ָ֮׷կ
    %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ך⡦ָ㉏겗ַ

    View full-size slide

  12. ˖ ة؎ىָؚٝ䖓חז׏ג׮״ֻծ⹛⡲ׅ׷ֿהָ⥂鏾׃׋ְ㜥
    さ׋ֻׁ׿ך鍑寸倯岀ָ֮׷կ
    ˖ +PC4DIFEVMFS 'JSFCBTF+PC%JTQBUDIFS "MBSN.BOBHFS
    #SPBEDBTU3FDFJWFST
    ˖ ⟃♴ך״ֲז鍑寸ٗآحؙ׾荈ⴓד剅ְגծ׋ֻׁ׿ךֿה׾
    罋䣁׃זָ׵׋ֻׁ׿ך"1*ךㄎן⳿׃׾剅ֻ䗳銲ָ֮׷կ
    %FGFSSBCMFHVBSBOUFFEFYFDVUJPO
    ך⡦ָ㉏겗ַ
    ֿ׸ח8PSL.BOBHFSָ㼎䘔ׅ׷

    View full-size slide

  13. ו׿זةأؙח8PSL.BOBHFS׾

    ⢪ֲץַֹ
    ˖ ءأذيָ،فٔ׾穄✪׃׋ה׃ג׮ծ⹛⡲⥂鏾׃׋ְةأؙ
    ך׋׭ח⢪ֲկ
    ˖ ،فٔךفٗإأָ穄✪׃ג׮ծ㸜Ⰻח穄✪דֹ׷ةأؙך׋
    ׭חכⵃ欽׃זְկ׉׸כ5ISFBE1PPMַ 3Y+BWBַDPSPVUJOF
    ׾אֲַץֹ

    ⳿ⰩIUUQTEFWFMPQFSBOESPJEDPNUPQJDMJCSBSJFTBSDIJUFDUVSFXPSLNBOBHFS

    View full-size slide

  14. ⢽ִלו׿זةأؙ
    ˖ ӧخ؎٦ز
    ˖ ӧًر؍،ؿ؋؎ٕך؟٦غ٦פך،حفٗ٦س
    ˖ ӧر٦ةךػ٦أהر٦ةك٦أפך⥂㶷
    ˖ –ػٖحزؕٓ٦׾䬄⳿׃ג*NBHF7JFX׾،حف
    ر٦ز
    ˖ –ر٦ة׾ػ٦أ׃ג7JFXך،حفر٦ز
    ˖ –铬ꆃךزٓٝؠؙءّٝ׾㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

    View full-size slide

  15. ⢽ִלו׿זةأؙ
    ˖ ӧخ؎٦ز
    ˖ ӧًر؍،ؿ؋؎ٕך؟٦غ٦פך،حفٗ٦س
    ˖ ӧر٦ةךػ٦أהر٦ةك٦أפך⥂㶷
    ˖ –ػٖحزؕٓ٦׾䬄⳿׃ג*NBHF7JFX׾،حف
    ر٦ز
    ˖ –ر٦ة׾ػ٦أ׃ג7JFXך،حفر٦ز
    ˖ –铬ꆃךزٓٝؠؙءّٝ׾㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ^
    ˖ 5ISFBE1PPM
    ˖ 3Y+BWB
    ˖ ,PUMJO
    $PSPVUJOF

    ׾⢪ֲ

    View full-size slide

  16. ⢽ִלו׿זةأؙ
    ˖ ӧخ؎٦ز
    ˖ ӧًر؍،ؿ؋؎ٕך؟٦غ٦פך،حفٗ٦س
    ˖ ӧر٦ةךػ٦أהر٦ةك٦أפך⥂㶷
    ˖ –ػٖحزؕٓ٦׾䬄⳿׃ג*NBHF7JFX׾،حف
    ر٦ز
    ˖ –ر٦ة׾ػ٦أ׃ג7JFXך،حفر٦ز
    ˖ –铬ꆃךزٓٝؠؙءّٝ׾㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    ^
    ˖ 5ISFBE1PPM
    ˖ 3Y+BWB
    ˖ ,PUMJO
    $PSPVUJOF

    ׾⢪ֲ
    ˖ 'PSFHSPVOE
    4FSWJDF׾⢪ֲ

    View full-size slide

  17. 8PSL.BOBHFSך⢪ְ倯

    View full-size slide

  18. 8PSL.BOBHFSך㼪Ⰵ
    implementation “android.arch.work:work-runtime:1.0.0-alpha01”
    ̔䗳갭
    implementation "android.arch.work:work-firebase:1.0.0-alpha01"
    ̔'JSFCBTF+PC%JTQBUDIFS׾⢪ֲ㜥さ䗳銲
    implementation “android.arch.work:work-runtime-ktx:1.0.0-alpha01"
    ̔,PUMJO׾⢪ֲ㜥さծ֮׏׋קֲָ知患ח剅ֽ׷
    androidTestImplementation “android.arch.work:work-testing:1.0.0-alpha01"
    ̔ذأز׾剅ֽ׷

    View full-size slide

  19. 8PSL.BOBHFSך⚥䗰הז׷ؙٓأ

    View full-size slide

  20. 8PSL.BOBHFSך⚥䗰הז׷ؙٓأ
    ˖ 8PSL⡲噟׾ׅ׷ؙٓأկ㹋ꥷחװ׶׋ְֿה׾竰䪫׃ג鎸鶢ׅ
    ׷

    View full-size slide

  21. 8PSL.BOBHFSך⚥䗰הז׷ؙٓأ
    ˖ 8PSL⡲噟׾ׅ׷ؙٓأկ㹋ꥷחװ׶׋ְֿה׾竰䪫׃ג鎸鶢ׅ
    ׷
    ˖ 8PSL3FRVFTU8PSLךؙٔؒأزךؙٓأկ

    View full-size slide

  22. 8PSL.BOBHFSך⚥䗰הז׷ؙٓأ
    ˖ 8PSL⡲噟׾ׅ׷ؙٓأկ㹋ꥷחװ׶׋ְֿה׾竰䪫׃ג鎸鶢ׅ
    ׷
    ˖ 8PSL3FRVFTU8PSLךؙٔؒأزךؙٓأկ
    ˖ 0OF5JNF8PSL3FRVFTU♧䏝ֹ׶ך8PSLך㹋遤ך㜥さך
    3FRVFTU

    View full-size slide

  23. 8PSL.BOBHFSך⚥䗰הז׷ؙٓأ
    ˖ 8PSL⡲噟׾ׅ׷ؙٓأկ㹋ꥷחװ׶׋ְֿה׾竰䪫׃ג鎸鶢ׅ
    ׷
    ˖ 8PSL3FRVFTU8PSLךؙٔؒأزךؙٓأկ
    ˖ 0OF5JNF8PSL3FRVFTU♧䏝ֹ׶ך8PSLך㹋遤ך㜥さך
    3FRVFTU
    ˖ 1FSJPEJD8PSL3FRVFTU粸׶鵤׃8PSLך㹋遤ׅ׷㜥さך
    3FRVFTU

    View full-size slide

  24. 8PSLFS׾⢪׏ג׫׷
    "EE)FMMP
    8PSLFS
    ˑ8PSME˒̔
    JOQVU PVUQVU
    ˑ)FMMP 8PSME˒
    ̔

    View full-size slide

  25. 8PSLFS׾⢪׏ג׫׷
    const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }

    View full-size slide

  26. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }
    8PSLFS׾竰䪫׃ג㹋鄲

    View full-size slide

  27. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }
    EP8PSL
    ׾㹋鄲׃ג
    㹋ꥷחֿך8PSLד
    װ׷ֿה׾剅ֻ

    View full-size slide

  28. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }
    EP8PSL
    ך⚥כ
    CBDLHSPVOEUISFBEד㹋遤ׁ׸׷

    View full-size slide

  29. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }
    䗳銲ח䘔ׄג䒷侧הז׷JOQVU%BUB׾《׸׷
    JOQVU%BUBכBOESPJEYXPSL%BUBؙٓأ 䖓鶢

    View full-size slide

  30. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }
    XPSLSVOUJNFLUYךUP8PSL%BUB
    ד
    BOESPJEYXPSL%BUBؙٓأח㢌䳔

    View full-size slide

  31. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    }
    PVUQVU%BUBח➿Ⰵׅ׷

    View full-size slide

  32. const val KEY = "key"
    class AddHelloWorker : Worker() {
    override fun doWork(): WorkerResult {
    val inputString = inputData.getString(KEY, "")
    val outputString = "Hello, $inputString"
    outputData = mapOf(KEY to outputString).toWorkData()
    return WorkerResult.SUCCESS
    }
    } 8PSL3FTVMU׾鵤ׅ
    46$$&44 '"*-63& 3&53:
    3&53:׾鵤ׇל׮ֲ♧䏝㹋遤דֹ׷

    View full-size slide

  33. ˖ ,#׃ַ⥂盖דֹזְךדر٦ةأز،ה׃ג䪔׏גכז׵
    זְ *MMFHBM4UBUF&YDFQUJPO׾䫎־׷

    ˖ ,FZָ4USJOH
    ˖ 7BMVFָفٔىذ؍ـ㘗ַ4USJOHծ׉ךꂁ⴨
    BOESPJEYXPSL%BUBؙٓأהכ

    View full-size slide

  34. 8PSLFS׾⢪׏ג׫׷
    val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    }

    View full-size slide

  35. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    }
    8PSL3FRVFTU׾⡲䧭

    View full-size slide

  36. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    TFU*OQVU%BUBדر٦ة׾床ׅ

    View full-size slide

  37. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    FORVFVF
    ד㹋遤

    View full-size slide

  38. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    8PSL.BOBHFSHFU4UBUVT#Z*Eד
    -JWF%BUB8PSL4UBUVTָ《䖤דֹ׷

    View full-size slide

  39. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    }
    JEכ8PSL3FRVFTUַ׵《䖤דֹ׷կ

    View full-size slide

  40. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    }
    })
    8PSL4UBUVT4UBUFד朐䡾׾鋅׷
    #-0$,&% $"/$&--&% &/26&6&%
    '"*-&% 36//*/( 46$$&&%&%ָ֮׷

    View full-size slide

  41. val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance().enqueue(workRequest)
    // workΛ؂ࢹ
    WorkManager.getInstance()
    .getStatusById(workRequest.id)
    .observe(this, Observer { workStatus ->
    workStatus ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    val outputData: Data = workStatus.outputData
    val output = outputData.getString(KEY, "default")
    toast(output)
    }
    else -> {
    }
    }
    })
    XPSL4UBUVTַ׵PVUQVU׃׋%BUBؙٓأח
    ،ؙإأדֹ׷

    View full-size slide

  42. 8PSL.BOBHFSך堣腉稱➜

    View full-size slide

  43. 8PSL.BOBHFSך堣腉稱➜
    ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷
    ˖ UIFO
    ד8PSL׾籬־׵׸׷
    ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷
    ˖ *OQVU.FSHFS׾⢪ֲ
    ˖ 8PSLח勴⟝׾אֽ׵׸׷
    ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷
    ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷
    ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ

    ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷

    View full-size slide

  44. UIFO
    ד8PSL׾籬־׵׸׷
    ˖ ⱖ溪ךؿ؍ٕة٦׾ַֽ׋䖓،حفٗ٦س׃׋ְהֹזוחⵃ欽ׅ׷
    ˖ ➙㔐כ8PSME)FMMP 8PSME)&--0 803-%׾װ׏ג׫׋
    WorkManager.getInstance()
    .beginWith(
    OneTimeWorkRequestBuilder()
    .setInputData(
    mapOf(
    KEY to "World"
    ).toWorkData()
    )
    .build()
    )
    .then(OneTimeWorkRequestBuilder().build())
    .enqueue()

    View full-size slide

  45. 8PSL.BOBHFSך堣腉稱➜
    ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷
    ˖ UIFO
    ד8PSL׾籬־׵׸׷
    ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷
    ˖ *OQVU.FSHFS׾⢪ֲ
    ˖ 8PSLח勴⟝׾אֽ׵׸׷
    ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷
    ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷
    ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ

    ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷

    View full-size slide

  46. 8PSLח勴⟝׾אֽ׵׸׷
    val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .setConstraints(Constraints.Builder().setRequiresCharging(true).build())
    .build()
    TFU$POTUSBJOUד鏣㹀׃ג֮־׷
    ⯍ꨵָ㨣ת׷הծ㹋遤ׁ׸׷

    ˖ طحزٙ٦ؙחאזָ׏גְ׷儗ך׫ծ

    ⯍ꨵ儗ך׫㹋遤זוך♳ꣲָאֽ׵׸׷

    View full-size slide

  47. 8PSL.BOBHFSך堣腉稱➜
    ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷
    ˖ UIFO
    ד8PSL׾籬־׵׸׷
    ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷
    ˖ *OQVU.FSHFS׾⢪ֲ
    ˖ 8PSLח勴⟝׾אֽ׵׸׷
    ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷
    ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷
    ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ

    ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷

    View full-size slide

  48. 8PSLחةؚ׾אֽג穾׶鴥׫זו
    ָדֹ׷
    val taggedRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "WorkManager").toWorkData())
    .addTag("tag")
    .build()
    WorkManager.getInstance().enqueue(taggedRequest)
    WorkManager.getInstance()
    .getStatusesByTag("tag")
    .observe(this, Observer> { workStatuses ->
    val workStatus = workStatuses?.getOrNull(0) ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    BEE5BHדةؚ鷄⸇
    ˖ 㥨ֹחط٦يأل٦أ׾⡲׸׷

    View full-size slide

  49. 8PSLחةؚ׾אֽג穾׶鴥׫זו
    ָדֹ׷
    val taggedRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "WorkManager").toWorkData())
    .addTag("tag")
    .build()
    WorkManager.getInstance().enqueue(taggedRequest)
    WorkManager.getInstance()
    .getStatusesByTag("tag")
    .observe(this, Observer> { workStatuses ->
    val workStatus = workStatuses?.getOrNull(0) ?: return@Observer
    when (workStatus.state) {
    State.SUCCEEDED -> {
    HFU4UBUVTFT#Z5BHד穾׶鴥׫
    ˖ ➭ח׮ةؚ⽃⡘דٍؗٝإٕ׃׋׶⳿勻׷

    View full-size slide

  50. 8PSL.BOBHFSך堣腉稱➜
    ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷
    ˖ UIFO
    ד8PSL׾籬־׵׸׷
    ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷
    ˖ *OQVU.FSHFS׾⢪ֲ
    ˖ 8PSLח勴⟝׾אֽ׵׸׷
    ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷
    ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷
    ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ

    ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷

    View full-size slide

  51. ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג
    穾׶鴥׫װծⵖ䖴ָדֹ׷
    val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance()
    .beginUniqueWork("hello",
    ExistingWorkPolicy.KEEP,
    workRequest
    ).enqueue()
    CFHJO6OJRVF8PSL׾⢪ֲ

    View full-size slide

  52. ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג
    穾׶鴥׫װծⵖ䖴ָדֹ׷
    val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance()
    .beginUniqueWork("hello",
    ExistingWorkPolicy.KEEP,
    workRequest
    ).enqueue()
    ずׄせ⵸ד8PSL׾㨣׭׋儗ךهٔء٦
    ˖ ,&&1⯓ח㨣׭׋8PSL׌ֽ㹋遤
    ˖ 3&1-"$&⯓ח㨣׭׋8PSL׾ٍؗٝإٕ׃ג⵴ꤐծ倜׃ְ8PSL׾Ꟛ㨣
    ˖ "11&/%⯓ח㨣׭׋8PSLך䖓חծ⚕倯遤ֲկ

    View full-size slide

  53. *OTJEF8PSL.BOBHFS

    View full-size slide

  54. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤
    ΍ת׆&YFDVUPSד㹋遤
    %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ

    ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח
    Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷
    Ύⴻ㹀׃גծ׉׸׊׸ך
    倯岀ד㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

    View full-size slide

  55. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤
    ΍ת׆&YFDVUPSד㹋遤
    %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ

    ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח
    Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷
    Ύⴻ㹀׃גծ׉׸׊׸ך
    倯岀ד㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
    %#42-JUF

    View full-size slide

  56. 8PSL.BOBHFSך⣛㶷ꟼ⤘
    BOESPJEBSDIXPSLXPSLSVOUJNFBMQIB
    ]BOESPJEBSDIMJGFDZDMFFYUFOTJPOT
    ]]BOESPJEBSDIMJGFDZDMFSVOUJNF

    ]]BOESPJEBSDIDPSFDPNNPO

    ]]BOESPJEBSDIDPSFSVOUJNF

    ]]DPNBOESPJETVQQPSUTVQQPSUGSBHNFOU

    ]]BOESPJEBSDIMJGFDZDMFDPNNPO

    ]]BOESPJEBSDIMJGFDZDMFMJWFEBUB
    ]]]BOESPJEBSDIDPSFSVOUJNF

    ]]]BOESPJEBSDIMJGFDZDMFMJWFEBUBDPSF

    ]]]=BOESPJEBSDIDPSFDPNNPO

    ]]=BOESPJEBSDIMJGFDZDMFWJFXNPEFM

    ]=BOESPJEBSDIQFSTJTUFODFSPPNSVOUJNF
    ]BOESPJEBSDIQFSTJTUFODFSPPNDPNNPO
    ]]=DPNBOESPJETVQQPSUTVQQPSUBOOPUBUJPOT
    ]BOESPJEBSDIQFSTJTUFODFECGSBNFXPSL
    ]]DPNBOESPJETVQQPSUTVQQPSUBOOPUBUJPOT
    ]]=BOESPJEBSDIQFSTJTUFODFEC
    ]]=DPNBOESPJETVQQPSUTVQQPSUBOOPUBUJPOT
    ]BOESPJEBSDIQFSTJTUFODFEC

    ]BOESPJEBSDIDPSFSVOUJNF

    ]=DPNBOESPJETVQQPSUTVQQPSUDPSFVUJMT

    ̒-JWF%BUB
    ̒7JFX.PEFM
    ̒3PPN
    3PPNח⣛㶷׃גְ׷

    View full-size slide

  57. 3PPN
    %#ך⚥׾4UFUIPד然钠דֹ׷

    View full-size slide

  58. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤
    ΍ת׆&YFDVUPSד㹋遤
    %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ

    ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח
    Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷
    Ύⴻ㹀׃גծ׉׸׊׸
    ך倯岀ד㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

    View full-size slide

  59. &YFDVUPSװ+PC4DIFEVMFSזוך

    鼅䫛ٗآحؙ
    public @NonNull List getSchedulers() {
    // Initialized at construction time. So no need to synchronize.
    if (mSchedulers == null) {
    mSchedulers = Arrays.asList(
    Schedulers.createBestAvailableBackgroundScheduler(mContext),
    new GreedyScheduler(mContext, this));
    }
    return mSchedulers;
    }
    ˖ (SFFEZ4DIFEVMFSה
    DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS׾⢪ֲ
    ˖ (SFFEZ4DIFEVMFS
    ˖ DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS
    ˖ ⡦ד㹋遤ׅ׷ַ鼅䫛ׅ׷ًاحس

    View full-size slide

  60. &YFDVUPSװ+PC4DIFEVMFSזוך

    鼅䫛ٗآحؙ
    public @NonNull List getSchedulers() {
    // Initialized at construction time. So no need to synchronize.
    if (mSchedulers == null) {
    mSchedulers = Arrays.asList(
    Schedulers.createBestAvailableBackgroundScheduler(mContext),
    new GreedyScheduler(mContext, this));
    }
    return mSchedulers;
    }
    ˖ (SFFEZ4DIFEVMFSה
    DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS
    ׾⢪ֲ
    ˖ (SFFEZ4DIFEVMFS

    ˖ DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS

    ˖ ⡦ד㹋遤ׅ׷ַ鼅䫛ׅ׷ًاحس

    View full-size slide

  61. 8PSL.BOBHFSךⰻ鿇㹋鄲
    5ISFBE1PPMח״׷㹋鄲
    ˖ 5ISFBE1PPMַ׵兛鸐ח㹋遤ׅ׷崧׸կ

    View full-size slide

  62. 8PSL.BOBHFSךⰻ鿇㹋鄲
    5ISFBE1PPMח״׷㹋鄲
    ず儗חאTDIFEVMFׅ׷
    (SFFEZ4DIFEVMFSה

    ֿך畭劣דכ
    4ZTUFN+PC4DIFEVMFS׾ⵃ欽ׅ׷

    View full-size slide

  63. 8PSL.BOBHFSךⰻ鿇㹋鄲
    5ISFBE1PPMח״׷㹋鄲
    (SFFEZ4DIFEVMFSַ׵

    5ISFBE1PPM׾穗ג
    XPSLFSEP8PSL
    ָ㹋遤ׁ׸׷

    View full-size slide

  64. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤
    ΍ת׆&YFDVUPSד㹋遤
    %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ

    ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח
    Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷
    Ύⴻ㹀׃גծ׉׸׊׸
    ך倯岀ד㹋遤
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

    View full-size slide

  65. &YFDVUPSװ+PC4DIFEVMFSזוך

    鼅䫛ٗآحؙ
    public @NonNull List getSchedulers() {
    // Initialized at construction time. So no need to synchronize.
    if (mSchedulers == null) {
    mSchedulers = Arrays.asList(
    Schedulers.createBestAvailableBackgroundScheduler(mContext),
    new GreedyScheduler(mContext, this));
    }
    return mSchedulers;
    }
    ˖ (SFFEZ4DIFEVMFSה
    DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS׾⢪ֲ
    ˖ (SFFEZ4DIFEVMFS
    ˖ DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS

    View full-size slide

  66. &YFDVUPSװ+PC4DIFEVMFSזוך

    鼅䫛ٗآحؙ
    public @NonNull List getSchedulers() {
    // Initialized at construction time. So no need to synchronize.
    if (mSchedulers == null) {
    mSchedulers = Arrays.asList(
    Schedulers.createBestAvailableBackgroundScheduler(mContext),
    new GreedyScheduler(mContext, this));
    }
    return mSchedulers;
    }
    ˖ (SFFEZ4DIFEVMFSה
    DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS׾⢪ֲ
    ˖ (SFFEZ4DIFEVMFS
    ˖ DSFBUF#FTU"WBJMBCMF#BDLHSPVOE4DIFEVMFS

    View full-size slide

  67. DSFBUF#FTU"WBJMBCMF#BDLHSPVOE

    4DIFEVMFS

    static @NonNull Scheduler
    createBestAvailableBackgroundScheduler(@NonNull Context
    context) {
    Scheduler scheduler;
    boolean enableFirebaseJobService = false;
    boolean enableSystemAlarmService = false;
    if (Build.VERSION.SDK_INT >=
    WorkManagerImpl.MIN_JOB_SCHEDULER_API_LEVEL) {
    scheduler = new SystemJobScheduler(context);
    setComponentEnabled(context,
    SystemJobService.class, true);
    Log.d(TAG, "Created SystemJobScheduler and
    enabled SystemJobService");
    } else {
    try {
    scheduler =
    tryCreateFirebaseJobScheduler(context);
    enableFirebaseJobService = true;

    View full-size slide

  68. static @NonNull Scheduler
    createBestAvailableBackgroundScheduler(@NonNull Context
    context) {
    Scheduler scheduler;
    boolean enableFirebaseJobService = false;
    boolean enableSystemAlarmService = false;
    if (Build.VERSION.SDK_INT >=
    WorkManagerImpl.MIN_JOB_SCHEDULER_API_LEVEL) {
    scheduler = new SystemJobScheduler(context);
    setComponentEnabled(context,
    SystemJobService.class, true);
    Log.d(TAG, "Created SystemJobScheduler and
    enabled SystemJobService");
    } else {
    try {
    scheduler =
    tryCreateFirebaseJobScheduler(context);
    enableFirebaseJobService = true;
    Log.d(TAG, "Created FirebaseJobScheduler");
    } catch (Exception e) {
    // Also catches the exception thrown if Play
    Services was not found on the device.
    scheduler = new
    SystemAlarmScheduler(context);
    "1*-FWFM⟃♳ד֮׸לծ
    4ZTUFN+PC4DIFEVMFS׾⢪ֲ

    View full-size slide

  69. boolean enableSystemAlarmService = false;
    if (Build.VERSION.SDK_INT >=
    WorkManagerImpl.MIN_JOB_SCHEDULER_API_LEVEL) {
    scheduler = new SystemJobScheduler(context);
    setComponentEnabled(context,
    SystemJobService.class, true);
    Log.d(TAG, "Created SystemJobScheduler and
    enabled SystemJobService");
    } else {
    try {
    scheduler =
    tryCreateFirebaseJobScheduler(context);
    enableFirebaseJobService = true;
    Log.d(TAG, "Created FirebaseJobScheduler");
    } catch (Exception e) {
    // Also catches the exception thrown if Play
    Services was not found on the device.
    scheduler = new
    SystemAlarmScheduler(context);
    enableSystemAlarmService = true;
    Log.d(TAG, "Created SystemAlarmScheduler");
    }
    }
    "1*-FWFM劢弫ד֮׸לծ
    'JSFCBTF+PC4DIFEVMFS׾
    鑐ׅ

    View full-size slide

  70. Log.d(TAG, "Created SystemJobScheduler and
    enabled SystemJobService");
    } else {
    try {
    scheduler =
    tryCreateFirebaseJobScheduler(context);
    enableFirebaseJobService = true;
    Log.d(TAG, "Created FirebaseJobScheduler");
    } catch (Exception e) {
    // Also catches the exception thrown if Play
    Services was not found on the device.
    scheduler = new
    SystemAlarmScheduler(context);
    enableSystemAlarmService = true;
    Log.d(TAG, "Created SystemAlarmScheduler");
    }
    }
    ׉׸ד׮تًד֮׸ל
    "MBSN.BOBHFS׾⢪ֲ

    View full-size slide

  71. DSFBUF#FTU"WBJMBCMF#BDLHSPVOE

    4DIFEVMFS

    static @NonNull Scheduler
    createBestAvailableBackgroundScheduler(@NonNull Context
    context) {
    Scheduler scheduler;
    boolean enableFirebaseJobService = false;
    boolean enableSystemAlarmService = false;
    if (Build.VERSION.SDK_INT >=
    WorkManagerImpl.MIN_JOB_SCHEDULER_API_LEVEL) {
    scheduler = new SystemJobScheduler(context);
    setComponentEnabled(context,
    SystemJobService.class, true);
    Log.d(TAG, "Created SystemJobScheduler and
    enabled SystemJobService");
    } else {
    try {
    scheduler =
    tryCreateFirebaseJobScheduler(context);
    enableFirebaseJobService = true;
    DSFBUF#FTU"WBJMBCMF#BDLHSPVOE

    4DIFEVMFS
    דכせ⵸ך鸐׶
    ⢪ִ׷♧殢ְְ4DIFEVMFS׾鵤ׅ

    View full-size slide

  72. 8PSL.BOBHFSךⰻ鿇㹋鄲
    +PC4DIFEVMFSח״׷㹋鄲
    ˖ +PC4DIFEVMFSח״׶㹋遤ׅ׷崧׸կ

    View full-size slide

  73. 8PSL.BOBHFSךⰻ鿇㹋鄲
    +PC4DIFEVMFSח״׷㹋鄲
    4ZTUFN+PC4DIFEVMFSח״׶4ZTUFN+PC4FSWJDFָ
    ㄎן⳿ׁ׸׷

    View full-size slide

  74. 8PSL.BOBHFSךⰻ鿇㹋鄲
    +PC4DIFEVMFSח״׷㹋鄲
    ׉ַֿ׵8PSL.BOBHFS*NQMTUBSU8PSLָㄎן⳿ׁ׸׷

    View full-size slide

  75. 8PSL.BOBHFSךⰻ鿇㹋鄲
    饯⹛Ⳣ椚
    ˖ .FSHFE.BOJGFTU׾然钠׃ג׫ת׃׋կ
    ˖ $POUFOU1SPWJEFSד،فָٔ饯⹛ׅ׷ة؎ىؚٝד荈⹛דⴱ劍⻉կ

    'JSFCBTFָずׄ倯岀דⴱ劍⻉׃ג鑧겗חז׶ת׃׋կ
    ˖ IUUQTSFCBTFHPPHMFCMPHDPNUBLFDPOUSPMPGZPVSSFCBTFJOJUPOIUNM
    ˖ #005@$0.1-&5&%ד畭劣ך饯⹛ד׮׍ׯ׿ה⹛ְגֻ׸תׅկ

    View full-size slide

  76. 8PSL.BOBHFSךذأز

    View full-size slide

  77. 8PSL.BOBHFSךذأز
    @Test
    fun test() {
    val testDriver = WorkManagerTestInitHelper.getTestDriver()
    val workRequest = OneTimeWorkRequestBuilder()
    .setInputData(mapOf(KEY to "World").toWorkData())
    .build()
    WorkManager.getInstance()
    .enqueue(workRequest)
    testDriver.setAllConstraintsMet(workRequest.id)
    val outputData =
    WorkManager.getInstance().synchronous().getStatusByIdSync(workRequest.id).out
    putData
    assertThat(outputData.getString(KEY, "none"), equalTo("Hello, World"))
    }
    5FTU%SJWFS
    ׾⢪׏גず劍涸ח⹛ַ׃גذأزדֹ׷

    View full-size slide

  78. 8PSL.BOBHFSך؟ٝفٕ
    㹋鄲

    View full-size slide

  79. 8PSL.BOBHFSך؟ٝفٕ㹋鄲
    ˖ HPPHMFTBNQMFT
    BOESPJEBSDIJUFDUVSF
    DPNQPOFOUTח֮׷
    ˖ IUUQTHJUIVCDPN
    HPPHMFTBNQMFT
    BOESPJEBSDIJUFDUVSF
    DPNQPOFOUT
    ˖ /BWJHBUJPOזו׮ֿֿח
    ֮׷ךד鋅ג׫׷ה葺ְ
    ה䙼ְתׅկ

    View full-size slide

  80. 8PSL.BOBHFSך؟ٝفٕ㹋鄲

    View full-size slide

  81. كأزفؙٓذ؍أ

    View full-size slide

  82. كأزفؙٓذ؍أ
    ˖ ءأذيָ،فָٔ穄✪׃׋ה׃ג׮ծ⹛⡲⥂鏾׃׋ְ
    ةأؙך׋׭ח⢪ֲկ
    ˖ %BUBؙٓأכر٦ةأز،דכזְךד3PPNזו׾⢪ֲ
    ˖ 㹋遤דֹ׷堣⠓׾ֲֲַָ״ֲח$POTUSBJOUד勴⟝׾剅ֿ
    ֲկ

    ⢽ִל歗⫷ך⸇䊨ה،حفٗ٦س׾ׅ׷儗ח،حفٗ٦
    سך8PSLחطحزٙ٦ָؙ䗳銲׌ה׃גֶֽלծ

    굲遤堣ח⛦׏גְ׷꟦ח歗⫷ך⸇䊨תדכ穄׻׏גծ籬
    ָ׏׋׵،حفٗ٦س׃גֻ׸׷זוָדֹ׷
    ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

    View full-size slide

  83. תה׭
    ˖ ءأذيָ،فָٔ穄✪׃׋ה׃ג׮ծ⹛⡲⥂鏾׃׋ְةأؙ
    ך׋׭ח⢪ֲկ
    ˖ 04ך⣛㶷ծ⢪ֲץֹ➬穈׫ךⴖ׶剏ִזוծהג׮嚂חז׷կ
    ن؎ٓ٦فٖ٦زָזׇֻ׷կ
    ˖ 8PSLחⵖ秈׾אֽ׸׷ծ籬־׵׸׷ծةָؚאֽ׵׸׷ծせ
    ⵸ָאֽ׵׸׷ծ朐䡾׾-JWF%BUBד《䖤דֹ׷կ
    ˖ ⢪ְ׫׍כ㢳ְךדծ⢪׏ג׫׷ה葺ׁ׉ֲկ

    View full-size slide

  84. ⿫罋项俱
    ˖ IUUQTEFWFMPQFSBOESPJEDPNUPQJDMJCSBSJFTBSDIJUFDUVSF
    XPSLNBOBHFS
    ˖ IUUQTXXXZPVUVCFDPNXBUDI W*S,P#'-X5/
    ˖ IUUQTXXXZPVUVCFDPNXBUDI WQ&S5Z2Q"
    ˖ IUUQTDPEFMBCTEFWFMPQFSTHPPHMFDPNDPEFMBCTBOESPJE
    XPSLNBOBHFS
    ˖ IUUQTHJUIVCDPNHPPHMFTBNQMFTBOESPJEBSDIJUFDUVSF
    DPNQPOFOUTUSFFNBTUFS8PSL.BOBHFS4BNQMF

    View full-size slide