Uhlelo lokusebenza
uhlu lokuhlola

    Oxhumana naye





    Ibhulogi yethu

    Sihlela ukubonakala kwakho! Ukusebenza okuhle nge-ONMA scout ukuthuthukiswa kohlelo lokusebenza lwe-android kuqinisekisiwe.

    Oxhumana naye
    ukuthuthukiswa kohlelo lokusebenza lwe-android

    Ibhulogi yethu


    Odinga Ukukwazi Mayelana Nokuthuthukiswa Kwezinhlelo Zokusebenza ze-Android

    ukuthuthukiswa kohlelo lokusebenza lwe-android

    Uma ungathanda ukufunda mayelana nokuthuthukiswa kohlelo lokusebenza lwe-Android, ufikile endaweni efanele. Kulesi sihloko, uzofunda ngeJava, Kotlin, Ukuhlukaniswa, kanye nezindawo zokusebenzelana zabasebenzisi bomdabu. Uzofunda futhi mayelana ne-Android SDK, I-GDR, kanye Nokwehlukana. Ngethemba, lolu lwazi luzokusiza ukuthi uqale ukwakha izinhlelo zokusebenza ngokushesha. Uma unemibuzo, ungesabi ukubuza!

    Java

    Uma uhlela ukuthuthukisa uhlelo lokusebenza lwe-Android, khona-ke i-Java ingase ibe ulimi olufanele ukusetshenziswa. I-Java iwulimi lokuhlela olusezingeni eliphezulu, kanye ne-syntax yayo ifana kakhulu neyezilimi zabantu. Ngenxa yalokho, Izinhlelo zokusebenza ze-Java zivumelana nezimo futhi ziyakaleka, futhi uze nomtapo wolwazi ocebile wamaphethini edizayini azenzakalelayo nezindlela ezihamba phambili. I-Java futhi ingumthombo ovulekile, okusho ukuthi kungenzeka ukusebenzisa ikhodi esebenziseka kabusha kumaphrojekthi ajwayelekile. I-Java yokuthuthukiswa kohlelo lokusebenza lwe-Android ingolunye lwezilimi zokuhlela ezivame kakhulu zokuthuthukiswa kohlelo lokusebenza lwe-Android.

    Uma ucabangela i-Java yokuthuthukisa uhlelo lokusebenza lwe-Android, uzodinga ukuqonda umehluko phakathi kwalolu limi lokuhlela kanye ne-Kotlin. Uma ubheka i-Java njengenketho yakho yokuqala, khumbula ukuthi kusengaphezu kwalokho 20 iminyaka emidala kunoKotlin. Noma kunjalo, uzodinga ukufunda zombili lezi zilimi uma ufuna ukuthola okuningi kule nkundla. Ungase ufune nokwakha uhlelo lokusebenza olusebenzisa izilimi zombili.

    I-Java inezinzuzo eziningi kune-Kotlin, kodwa futhi kunzima kancane ukufunda. Ngenkathi i-Java isetshenziswa kabanzi ekuthuthukisweni kwe-Android, I-Kotlin isetshenziswa kancane kakhulu. Nakuba i-Kotlin kulula ukufunda kune-Java, kuyisinqumo esihle sokuthuthukiswa kwe-Android. I-Kotlin ifundeka kalula kune-Java futhi iwulimi i-Google eluncoma ekuthuthukisweni kwe-Android. Iphinde inikeze ukwesekwa okwengeziwe ekuthuthukisweni kwe-Android.

    Kotlin

    Uma uhlela ukusebenzisa ulimi lokuhlela lwe-Kotlin ekuthuthukisweni kohlelo lokusebenza lwe-Android, kunezinto ezimbalwa okufanele uzazi kuqala. Nakuba inikeza izinzuzo eziningana, kudinga isikhathi esincane sokufunda. Akulula njengezinye izilimi zokuhlela futhi kuzodinga ukubhala kabusha amaphrojekthi kanye nokuwalungiselela. Bese futhi, uma uzimisele ngokudala uhlelo lokusebenza lombulali, uzobe ulungele ukubhekana nanoma iyiphi inselele eza endleleni yakho. Enye into okufanele uyikhumbule ukuthi i-Kotlin izokwenza inqubo yokuqalisa iphrojekthi yakho ngokushesha.

    Kusukela yethulwa enkomfeni ye-Google I/O ngo 2017, I-Kotlin isizuze ukuthandwa okukhulu futhi ngokushesha idlula i-Java njengolimi lokuhlela oludume kakhulu lwe-Android. Lolu limi olusha lufushanisiwe futhi aluthambekele kakhulu kwikhodi ye-boilerplate. Futhi kunciphisa isidingo sokuhlolwa okubanzi nokugcinwa kohlelo lokusebenza, okubangela iziphazamisi ezincane nokuphahlazeka okuncane. Uma kuqhathaniswa ne-Java, Ikhodi ye-Kotlin incane kakhulu futhi imfushane kakhulu.

    Ngenkathi i-Java sekuyisikhathi eside iyisisekelo semikhiqizo ye-Android, ulimi olusha i-Kotlin lenze abathuthukisi abaningi bacabange kabusha indlela yabo yokudala izinhlelo zokusebenza. I-Kotlin yadalwa i-JetBrains yaseRussia yokuqala futhi yakhiwe emshinini we-Java virtual. Kufakiwe, ulimi lokuhlela olusebenzayo olusebenza emshinini we-Java virtual. Umgomo we-Kotlin uwukunikeza izikhathi zokuhlanganisa ezisheshayo nokwenza izinhlelo zokusebenza zibe lula ukuzinakekela.

    Ukuhlukaniswa

    Ukusebenzisa i-Fragmentation ekuthuthukisweni kohlelo lokusebenza lwe-Android kuvumela onjiniyela ukuthi basebenzise ukushaya emuva ukuze balawule umjikelezo wempilo wezingcezu. Lezi zindlela zivame ukusetshenziswa ezinhlelweni zokusebenza ze-Android, futhi ufake ku-Okudala, kuQala, ekuPhumeni, onDestroy, futhi ku-Resume. Ukusebenzisa ama-callbacks kungenza izingcezu zakho zibe modular, ezimele, kanye nezingxenye ezingasetshenziswa kabusha. Bangakwazi futhi ukusiza uhlelo lwakho lokusebenza ukuthi luphendule kuma-callback ahlukahlukene kanye nezinhloso, futhi ingadlulisela izimpikiswano ekuqaliseni komsebenzi womzali.

    Ekuthuthukisweni kohlelo lokusebenza lwe-Android, ucezu luyingxenye yomsebenzisi obonakalayo. Kuye ngosayizi wesikrini wedivayisi, izingcezu kufanele zizimele futhi zibe yi-modular. Izingcezu zingasetshenziswa kabusha phakathi kwemisebenzi, futhi ingahlanganiswa ukudala umsebenzi owodwa. Ngaphezu kwalokho, izingcezu zingasetshenziswa kabusha ezikrinini ezahlukene. Ukuhlukaniswa kwenza kube lula konjiniyela ukugcina ikhodi yohlelo lokusebenza.

    Ukusebenzisa izingcezu ekuthuthukisweni kohlelo lokusebenza lwe-Android kuqeda inkinga yezinto ezingasebenzisi lutho ze-UI. Esikhundleni sokwenza izingcezu njengefa kusuka kuMsebenzi, ungakha Izingcezu ezihlukene zesici sefomu ngalinye. Izingcezu zinezibopho ze-UI eziqondene naleyo nto yefomu, ukuze Umsebenzi wakho ukwazi ukuthumela isibopho se-UI Kucezu olufanele. Isiqeshana singaba nezingxenye eziningi, njengezinkinobho noma amamenyu.

    Ukuhlukana ekuthuthukisweni kohlelo lokusebenza lwe-Android kuyinkinga eqhubekayo. Abakhiqizi abaningi bemishini ephathwayo benza ngendlela oyifisayo i-Android OS ukuze ilingane nedivayisi ethile. Lokhu kuholela ekuhlukeni okuningi kukhodi, okusho ukuthi izinguqulo ezahlukene zohlelo lokusebenza zizosebenza ngendlela ehlukile. Okonjiniyela, lokhu kungaba inselele enkulu, kodwa i-Google isebenzela ukulungisa le nkinga. Ngokunikela ngohlelo lokusebenzisana lwe-Android, onjiniyela bangahlunga kalula ukuthi imaphi amadivayisi nezinguqulo abangazithuthukisa.

    Izixhumanisi zabasebenzisi bomdabu

    Izixhumanisi zabasebenzisi bomdabu ekuthuthukisweni kohlelo lokusebenza lwe-Android zingadalwa ngokuhlanganisa uhlelo lwe-Java ne-XML. Ukubuka kwe-Android kunikeza ukuziphatha kwesakhiwo, kuyilapho ama-ViewGroups eyizingxenye zomdabu ezingangeza izici zedizayini noma ukuziphatha okujwayelekile. Ngokwesibonelo, iqembu lokubuka le-PageViewer lihlinzeka ngokuswayipha okuvundlile esipheqululini, efana nohlelo lokusebenza lwe-Google. Uhlelo lokusebenza lungasebenzisa kokubili ukubuka kanye ne-ViewGroups ukuze kuqinisekiswe ukuthi kulula ukuyisebenzisa.

    Nakuba kunezinzuzo eziningi zokusebenzisa indlela yokuklama eyi-hybrid, akusona njalo isisombululo esingabizi kakhulu. Onjiniyela abaningi be-iOS bathola ukuthi izindleko zokuthuthukisa uhlelo lokusebenza kuzo zombili izinkundla zinkulu kakhulu. Ngenhlanhla, izinhlaka ezimbalwa ezinamandla zikwenza kube lula ukusebenzisa idizayini ye-UI yomdabu ku-Android. Kodwa abaklami be-UI kufanele futhi bacabange ukuthi imihlahlandlela ye-UI yehlukile ku-iOS ne-Android. Ukusebenzisa i-Android ngokwezifiso kungase kudinge umzamo owengeziwe, ikakhulukazi uma inhloso eyinhloko yohlelo lokusebenza ukukhomba abasebenzisi be-iPhone.

    Abasebenzisi be-Android bangafinyelela izinhlelo zokusebenza ngokusebenzisa isixhumi esibonakalayo sezingxenyekazi zekhompuyutha kanye nesixhumi esibonakalayo somsebenzisi se-OS (I-UI). I-UI iwumfanekiso obonakalayo wesistimu ethile, njengesikrini sasekhaya kanye nephaneli yezaziso. I-UI iyikho kokubili ihadiwe nesofthiwe futhi ingafaka amawindi ohlelo, Amakhasi ewebhu, izikrini zohlelo lokusebenza lweselula, namageji nezibani. I-Native UIs iphinda inikeze inzuzo yokusebenza ngokugcwele kumadivayisi ahlukahlukene.

    Ukuhlola

    Kunezinhlobo ezimbili eziyinhloko zokuhlola uhlelo lokusebenza lwe-Android: ukuhlolwa kweyunithi nokuhlolwa kokuhlanganisa. Ukuhlolwa kweyunithi izingcezu ezincane zekhodi eziqinisekisa ukusebenza; ukuhlola kokuphela kuqaliswa kudivayisi yangempela, ngenkathi izivivinyo zokuhlanganisa ziqinisekisa ukuthi uhlelo lokusebenza lusebenza kanjani kuwo wonke amamojula. Ukuhlolwa kokuhlanganisa kufanele kuhambisane nendawo yonke 20% yenani eliphelele lokuhlolwa. Uma ungunjiniyela omusha, kungaba usizo ukusebenzisa i-codelab yokuhlola ukuze ufunde kabanzi mayelana nale nqubo.

    Uzodinga ukudala i-APK ngaphambi kokuthi uqale ukubhala izivivinyo. Ukuhlola okunamathuluzi kusebenza kudivayisi futhi kudinga ukuthi ufake uhlaka lwe-Android, etholakala nge-Android ADB. Ukuqinisekisa ukuthi konke kuyasebenza, uzofuna ukwenza isiqiniseko sokuthi unamalabhulali okuhlola adingekayo. Uma ilabhulali yakho yokuhlola ingazifaki lezi, uzoba nenkinga yokuyihlanganisa. Ngenhlanhla, izivivinyo zezinsimbi ziwusizo ngendlela emangalisayo futhi kulula ukuzisebenzisa.

    Ukuze wenze izivivinyo endaweni emshinini wakho wokuthuthukisa, sebenzisa i-Robolectric. Lolu hlaka luklanyelwe ukusebenza kumsingathi wendawo futhi lulandela izinqubo ezingcono kakhulu zokuhlekisa. I-Robolectric iwusizo kakhulu ekuhloleni izinhlelo zokusebenza ze-Android ngoba ikuvumela ukuthi wenze izivivinyo ekuncikeni ku-Android futhi iyashesha futhi ihlanzekile ekuhloleni iyunithi.. Ingase futhi ilingise isikhathi sokusebenza ku-Android 4.1 futhi isekela amanga anakekelwa umphakathi. Ngale ndlela, ungahlola ikhodi yakho ngaphandle kwe-emulator.

    Ukusabalalisa

    Ziningi iziteshi zokumaketha zezinhlelo zokusebenza ze-Android. Eyokuqala nokuhamba phambili yi-Google Play. Le ndawo yemakethe inkulu kunawo wonke futhi ivumela onjiniyela ukuthi basabalalise izinhlelo zabo zokusebenza ngezindlela ezahlukahlukene. Ngaphezu kwe-App Store ne-Google Play, I-Android inezinye iziteshi ezimbalwa zokusabalalisa. Uma uhlelo lwakho lokusebenza luhlose ukufinyelela izethameli ezinkulu, kungaba umqondo omuhle ukuwahlola wonke. Kukhona nezinye izindlela ezahlukahlukene zokusabalalisa uhlelo lwakho lokusebenza, kufaka phakathi izimakethe zamaselula njenge-Amazon App Store, iTunes Store, kanye ne-Google Play Isitolo.

    Uma uhlelo lwakho lokusebenza lwe-Android seluqediwe, ungakwazi ukusabalalisa kubahloli bakho. Kwalokhu, uzodinga ukudala i-frontend elula ezovumela abahloli ukuthi bafake uhlelo lokusebenza. Uma abahloli sebelande uhlelo lokusebenza, kufanele bangene ngemvume kuma-akhawunti abo noma bavule i-imeyili kumadivayisi abo eselula. Lokhu kungase kudle isikhathi esiningi futhi kuzoholela ezinguqukweni ezingekho. Kungenjalo, ungasebenzisa ukusatshalaliswa kokuhlola kwenkundla yesiphambano.

    Enye inzuzo yokuthuthukiswa kohlelo lokusebenza lwe-Android ukuthi kulula ukwenza ngendlela oyifisayo. Ngoba i-Android iyinkundla yokwenza ngokwezifiso kakhulu, abathuthukisi bangayilungisa kalula ukuze ihlangabezane nezidingo zabo zebhizinisi. Ngaphezu kwalokho, nge-Android, ayikho inkundla yokusabalalisa eyodwa, ngakho onjiniyela bangakha iziteshi eziningi zokusabalalisa zezinhlelo zabo zokusebenza. Lokhu kusho ukuthi bangafinyelela izethameli eziningi eziqondiwe, okuyinzuzo enkulu kunoma yiliphi ibhizinisi. Futhi, njengoba inkundla ingumthombo ovulekile, lokhu kunikeza abakhiqizi izinketho eziningi nenkululeko yokudala izinhlelo zokusebenza ze-Android.

    ividiyo yethu
    Thola isilinganiso samahhala