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

WorkManager

7166bc2cbc462ab5fd1987a76d0fe709?s=47 takahirom
May 22, 2018
1.9k

 WorkManager

7166bc2cbc462ab5fd1987a76d0fe709?s=128

takahirom

May 22, 2018
Tweet

Transcript

  1. 8PSL.BOBHFS UBLBIJSPN

  2. 荈ⴓחאְג ˖ UBLBIJSPN !OFX@SVOOBCMF  ˖ 劤せכ嬁「䃨峔 ׭׿ׄױ׋ַמ׹  ˖

    "OESPJEָ㥨ֹדׅկ ˖ "CFNB57ך"OESPJE،فٔ׾⡲׏גְתׅկ ˖ ջ(PPHMF*0ًٌ 끅ְ׋הֿ׹ռהְֲ 2JJUB׾剅ֹת׃׋
  3. 8PSL.BOBHFSהכ "OESPJE+FUQBDL"SDIJUFDUVSFך⚥ךא (PPHMF*0ד涪邌 ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

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

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

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

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

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

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

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

    "TZOD5BTLזו ⦐ּ׵ְ֮ ׷  ˖ "OESPJEךغحذٔ٦剑黝⻉ך堣腉׮׋ֻׁ׿֮׷ ˖ %P[FNPEF "QQTUBOECZ -JNJUFEJNQMJDJUCSPBEDBTUT  3FMFBTFDBDIFEXBLFMPDLT 1ד涪邌ׁ׸׋׮ך׾ろ׭׷ הծ֮ה ⦐ּ׵ְ֮׷ %FGFSSBCMFHVBSBOUFFEFYFDVUJPO ך⡦ָ㉏겗ַ
  11. ˖ ة؎ىָؚٝ䖓חז׏ג׮״ֻծ⹛⡲ׅ׷ֿהָ⥂鏾׃׋ְ㜥 さ׋ֻׁ׿ך鍑寸倯岀ָ֮׷կ ˖ +PC4DIFEVMFS 'JSFCBTF+PC%JTQBUDIFS "MBSN.BOBHFS  #SPBEDBTU3FDFJWFST ˖

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

    ⟃♴ך״ֲז鍑寸ٗآحؙ׾荈ⴓד剅ְגծ׋ֻׁ׿ךֿה׾ 罋䣁׃זָ׵׋ֻׁ׿ך"1*ךㄎן⳿׃׾剅ֻ䗳銲ָ֮׷կ %FGFSSBCMFHVBSBOUFFEFYFDVUJPO ך⡦ָ㉏겗ַ ֿ׸ח8PSL.BOBHFSָ㼎䘔ׅ׷
  13. ו׿זةأؙח8PSL.BOBHFS׾
 ⢪ֲץַֹ ˖ ءأذيָ،فٔ׾穄✪׃׋ה׃ג׮ծ⹛⡲⥂鏾׃׋ְةأؙ ך׋׭ח⢪ֲկ ˖ ،فٔךفٗإأָ穄✪׃ג׮ծ㸜Ⰻח穄✪דֹ׷ةأؙך׋ ׭חכⵃ欽׃זְկ׉׸כ5ISFBE1PPMַ 3Y+BWBַDPSPVUJOF ׾אֲַץֹ

    ⳿ⰩIUUQTEFWFMPQFSBOESPJEDPNUPQJDMJCSBSJFTBSDIJUFDUVSFXPSLNBOBHFS
  14. ⢽ִלו׿זةأؙ ˖ ӧخ؎٦ز ˖ ӧًر؍،ؿ؋؎ٕך؟٦غ٦פך،حفٗ٦س ˖ ӧر٦ةךػ٦أהر٦ةك٦أפך⥂㶷 ˖ –ػٖحزؕٓ٦׾䬄⳿׃ג*NBHF7JFX׾،حف ر٦ز

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

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

    ˖ –ر٦ة׾ػ٦أ׃ג7JFXך،حفر٦ز ˖ –铬ꆃךزٓٝؠؙءّٝ׾㹋遤 ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/ ^ ˖ 5ISFBE1PPM ˖ 3Y+BWB ˖ ,PUMJO $PSPVUJOF
 ׾⢪ֲ ˖ 'PSFHSPVOE 4FSWJDF׾⢪ֲ
  17. 8PSL.BOBHFSך⢪ְ倯

  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" ̔ذأز׾剅ֽ׷
  19. 8PSL.BOBHFSך⚥䗰הז׷ؙٓأ

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

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

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

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

    1FSJPEJD8PSL3FRVFTU粸׶鵤׃8PSLך㹋遤ׅ׷㜥さך 3FRVFTU
  24. 8PSLFS׾⢪׏ג׫׷ "EE)FMMP 8PSLFS ˑ8PSME˒̔ JOQVU PVUQVU ˑ)FMMP 8PSME˒ ̔

  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 } }
  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׾竰䪫׃ג㹋鄲
  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ד װ׷ֿה׾剅ֻ
  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ד㹋遤ׁ׸׷
  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ؙٓأ 䖓鶢
  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ؙٓأח㢌䳔
  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ח➿Ⰵׅ׷
  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:׾鵤ׇל׮ֲ♧䏝㹋遤דֹ׷
  33. ˖ ,#׃ַ⥂盖דֹזְךדر٦ةأز،ה׃ג䪔׏גכז׵ זְ *MMFHBM4UBUF&YDFQUJPO׾䫎־׷  ˖ ,FZָ4USJOH ˖ 7BMVFָفٔىذ؍ـ㘗ַ4USJOHծ׉ךꂁ⴨ BOESPJEYXPSL%BUBؙٓأהכ

  34. 8PSLFS׾⢪׏ג׫׷ val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .build() WorkManager.getInstance().enqueue(workRequest)

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

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

    workΛ؂ࢹ WorkManager.getInstance() .getStatusById(workRequest.id) .observe(this, Observer<WorkStatus?> { 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דر٦ة׾床ׅ
  37. val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .build() WorkManager.getInstance().enqueue(workRequest) //

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

    workΛ؂ࢹ WorkManager.getInstance() .getStatusById(workRequest.id) .observe(this, Observer<WorkStatus?> { 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ָ《䖤דֹ׷
  39. val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .build() WorkManager.getInstance().enqueue(workRequest) //

    workΛ؂ࢹ WorkManager.getInstance() .getStatusById(workRequest.id) .observe(this, Observer<WorkStatus?> { 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ַ׵《䖤דֹ׷կ
  40. val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .build() WorkManager.getInstance().enqueue(workRequest) //

    workΛ؂ࢹ WorkManager.getInstance() .getStatusById(workRequest.id) .observe(this, Observer<WorkStatus?> { 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$$&&%&%ָ֮׷
  41. val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .build() WorkManager.getInstance().enqueue(workRequest) //

    workΛ؂ࢹ WorkManager.getInstance() .getStatusById(workRequest.id) .observe(this, Observer<WorkStatus?> { 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ؙٓأח ،ؙإأדֹ׷
  42. 8PSL.BOBHFSך堣腉稱➜

  43. 8PSL.BOBHFSך堣腉稱➜ ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷ ˖ UIFO ד8PSL׾籬־׵׸׷ ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷ ˖ *OQVU.FSHFS׾⢪ֲ

    ˖ 8PSLח勴⟝׾אֽ׵׸׷ ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷ ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷ ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ
 ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷
  44. UIFO ד8PSL׾籬־׵׸׷ ˖ ⱖ溪ךؿ؍ٕة٦׾ַֽ׋䖓،حفٗ٦س׃׋ְהֹזוחⵃ欽ׅ׷ ˖ ➙㔐כ8PSME)FMMP 8PSME)&--0 803-%׾װ׏ג׫׋ WorkManager.getInstance() .beginWith(

    OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData( mapOf( KEY to "World" ).toWorkData() ) .build() ) .then(OneTimeWorkRequestBuilder<UpperCaseWorker>().build()) .enqueue()
  45. 8PSL.BOBHFSך堣腉稱➜ ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷ ˖ UIFO ד8PSL׾籬־׵׸׷ ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷ ˖ *OQVU.FSHFS׾⢪ֲ

    ˖ 8PSLח勴⟝׾אֽ׵׸׷ ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷ ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷ ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ
 ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷
  46. 8PSLח勴⟝׾אֽ׵׸׷ val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .setConstraints(Constraints.Builder().setRequiresCharging(true).build()) .build()

    TFU$POTUSBJOUד鏣㹀׃ג֮־׷ ⯍ꨵָ㨣ת׷הծ㹋遤ׁ׸׷ ˖ طحزٙ٦ؙחאזָ׏גְ׷儗ך׫ծ
 ⯍ꨵ儗ך׫㹋遤זוך♳ꣲָאֽ׵׸׷
  47. 8PSL.BOBHFSך堣腉稱➜ ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷ ˖ UIFO ד8PSL׾籬־׵׸׷ ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷ ˖ *OQVU.FSHFS׾⢪ֲ

    ˖ 8PSLח勴⟝׾אֽ׵׸׷ ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷ ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷ ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ
 ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷
  48. 8PSLחةؚ׾אֽג穾׶鴥׫זו ָדֹ׷ val taggedRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "WorkManager").toWorkData()) .addTag("tag")

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

    .build() WorkManager.getInstance().enqueue(taggedRequest) WorkManager.getInstance() .getStatusesByTag("tag") .observe(this, Observer<List<WorkStatus>> { workStatuses -> val workStatus = workStatuses?.getOrNull(0) ?: return@Observer when (workStatus.state) { State.SUCCEEDED -> { HFU4UBUVTFT#Z5BHד穾׶鴥׫ ˖ ➭ח׮ةؚ⽃⡘דٍؗٝإٕ׃׋׶⳿勻׷
  50. 8PSL.BOBHFSך堣腉稱➜ ˖ 8PSLך⣛㶷ؚٓؿָ⡲׸׷ ˖ UIFO ד8PSL׾籬־׵׸׷ ˖ 3Y+BWBך[JQ׫׋ְזֿהָדֹ׷ ˖ *OQVU.FSHFS׾⢪ֲ

    ˖ 8PSLח勴⟝׾אֽ׵׸׷ ˖ -JWF%BUBד➙ך朐䡾ָ鋅׵׸׷ ˖ 8PSLחةؚ׾אֽג穾׶鴥׫זוָדֹ׷ ˖ ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג穾׶鴥׫װծ
 ずׄせ⵸ָ崧׸׋הֹךⵖ䖴ָדֹ׷
  51. ثؑ؎ٝꟚ㨣儗חِص٦ؙזせ⵸׾אֽג 穾׶鴥׫װծⵖ䖴ָדֹ׷ val workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .setInputData(mapOf(KEY to "World").toWorkData()) .build()

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

    WorkManager.getInstance() .beginUniqueWork("hello", ExistingWorkPolicy.KEEP, workRequest ).enqueue() ずׄせ⵸ד8PSL׾㨣׭׋儗ךهٔء٦ ˖ ,&&1⯓ח㨣׭׋8PSL׌ֽ㹋遤 ˖ 3&1-"$&⯓ח㨣׭׋8PSL׾ٍؗٝإٕ׃ג⵴ꤐծ倜׃ְ8PSL׾Ꟛ㨣 ˖ "11&/%⯓ח㨣׭׋8PSLך䖓חծ⚕倯遤ֲկ
  53. *OTJEF8PSL.BOBHFS

  54. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤 ΍ת׆&YFDVUPSד㹋遤 %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ
 ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷ Ύⴻ㹀׃גծ׉׸׊׸ך 倯岀ד㹋遤 ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

  55. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤 ΍ת׆&YFDVUPSד㹋遤 %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ
 ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷ Ύⴻ㹀׃גծ׉׸׊׸ך 倯岀ד㹋遤 ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/ %#42-JUF

  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ח⣛㶷׃גְ׷
  57. 3PPN %#ך⚥׾4UFUIPד然钠דֹ׷

  58. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤 ΍ת׆&YFDVUPSד㹋遤 %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ
 ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷ Ύⴻ㹀׃גծ׉׸׊׸ ך倯岀ד㹋遤 ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

  59. &YFDVUPSװ+PC4DIFEVMFSזוך
 鼅䫛ٗآحؙ public @NonNull List<Scheduler> 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 ˖ ⡦ד㹋遤ׅ׷ַ鼅䫛ׅ׷ًاحس
  60. &YFDVUPSװ+PC4DIFEVMFSזוך
 鼅䫛ٗآحؙ public @NonNull List<Scheduler> 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 ˖ ⡦ד㹋遤ׅ׷ַ鼅䫛ׅ׷ًاحس
  61. 8PSL.BOBHFSךⰻ鿇㹋鄲 5ISFBE1PPMח״׷㹋鄲 ˖ 5ISFBE1PPMַ׵兛鸐ח㹋遤ׅ׷崧׸կ

  62. 8PSL.BOBHFSךⰻ鿇㹋鄲 5ISFBE1PPMח״׷㹋鄲 ず儗חאTDIFEVMFׅ׷ (SFFEZ4DIFEVMFSה
 ֿך畭劣דכ 4ZTUFN+PC4DIFEVMFS׾ⵃ欽ׅ׷

  63. 8PSL.BOBHFSךⰻ鿇㹋鄲 5ISFBE1PPMח״׷㹋鄲 (SFFEZ4DIFEVMFSַ׵
 5ISFBE1PPM׾穗ג XPSLFSEP8PSL ָ㹋遤ׁ׸׷

  64. 8PSL.BOBHFSךⰻ鿇㹋鄲ך㛇劤 ΍ת׆&YFDVUPSד㹋遤 %#ח䞔㜠׾Ⰵ׸גַ׵ծ΍ת׆&YFDVUPSד㹋遤ׅ׷կ
 ׉ך꟦חفٗإأָ姺ת׏ג׮葺ְ״ֲח Ύ+PC4DIFEVMFSזוַ׵&YFDVUPS׾㹋遤ׅ׷ Ύⴻ㹀׃גծ׉׸׊׸ ך倯岀ד㹋遤 ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/

  65. &YFDVUPSװ+PC4DIFEVMFSזוך
 鼅䫛ٗآحؙ public @NonNull List<Scheduler> 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
  66. &YFDVUPSװ+PC4DIFEVMFSזוך
 鼅䫛ٗآحؙ public @NonNull List<Scheduler> 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
  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;
  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׾⢪ֲ
  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׾ 鑐ׅ
  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׾⢪ֲ
  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׾鵤ׅ
  72. 8PSL.BOBHFSךⰻ鿇㹋鄲 +PC4DIFEVMFSח״׷㹋鄲 ˖ +PC4DIFEVMFSח״׶㹋遤ׅ׷崧׸կ

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

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

  75. 8PSL.BOBHFSךⰻ鿇㹋鄲 饯⹛Ⳣ椚 ˖ .FSHFE.BOJGFTU׾然钠׃ג׫ת׃׋կ ˖ $POUFOU1SPWJEFSד،فָٔ饯⹛ׅ׷ة؎ىؚٝד荈⹛דⴱ劍⻉կ
 'JSFCBTFָずׄ倯岀דⴱ劍⻉׃ג鑧겗חז׶ת׃׋կ ˖ IUUQTSFCBTFHPPHMFCMPHDPNUBLFDPOUSPMPGZPVSSFCBTFJOJUPOIUNM ˖

    #005@$0.1-&5&%ד畭劣ך饯⹛ד׮׍ׯ׿ה⹛ְגֻ׸תׅկ
  76. 8PSL.BOBHFSךذأز

  77. 8PSL.BOBHFSךذأز @Test fun test() { val testDriver = WorkManagerTestInitHelper.getTestDriver() val

    workRequest = OneTimeWorkRequestBuilder<AddHelloWorker>() .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 ׾⢪׏גず劍涸ח⹛ַ׃גذأزדֹ׷
  78. 8PSL.BOBHFSך؟ٝفٕ 㹋鄲

  79. 8PSL.BOBHFSך؟ٝفٕ㹋鄲 ˖ HPPHMFTBNQMFT BOESPJEBSDIJUFDUVSF DPNQPOFOUTח֮׷ ˖ IUUQTHJUIVCDPN HPPHMFTBNQMFT BOESPJEBSDIJUFDUVSF DPNQPOFOUT

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

  81. كأزفؙٓذ؍أ

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

    سך8PSLחطحزٙ٦ָؙ䗳銲׌ה׃גֶֽלծ
 굲遤堣ח⛦׏גְ׷꟦ח歗⫷ך⸇䊨תדכ穄׻׏גծ籬 ָ׏׋׵،حفٗ٦س׃גֻ׸׷זוָדֹ׷ ⳿ⰩIUUQTZPVUVCF*S,P#'-X5/
  83. תה׭ ˖ ءأذيָ،فָٔ穄✪׃׋ה׃ג׮ծ⹛⡲⥂鏾׃׋ְةأؙ ך׋׭ח⢪ֲկ ˖ 04ך⣛㶷ծ⢪ֲץֹ➬穈׫ךⴖ׶剏ִזוծהג׮嚂חז׷կ ن؎ٓ٦فٖ٦زָזׇֻ׷կ ˖ 8PSLחⵖ秈׾אֽ׸׷ծ籬־׵׸׷ծةָؚאֽ׵׸׷ծせ ⵸ָאֽ׵׸׷ծ朐䡾׾-JWF%BUBד《䖤דֹ׷կ

    ˖ ⢪ְ׫׍כ㢳ְךדծ⢪׏ג׫׷ה葺ׁ׉ֲկ
  84. ⿫罋项俱 ˖ IUUQTEFWFMPQFSBOESPJEDPNUPQJDMJCSBSJFTBSDIJUFDUVSF XPSLNBOBHFS ˖ IUUQTXXXZPVUVCFDPNXBUDI W*S,P#'-X5/ ˖ IUUQTXXXZPVUVCFDPNXBUDI WQ&S5Z2Q"

    ˖ IUUQTDPEFMBCTEFWFMPQFSTHPPHMFDPNDPEFMBCTBOESPJE XPSLNBOBHFS ˖ IUUQTHJUIVCDPNHPPHMFTBNQMFTBOESPJEBSDIJUFDUVSF DPNQPOFOUTUSFFNBTUFS8PSL.BOBHFS4BNQMF