Sihlela ukubonakala kwakho! Ukusebenza okuhle nge-ONMA scout ukuthuthukiswa kohlelo lokusebenza lwe-android kuqinisekisiwe.
Oxhumana naye
Nge-Android, kulula ukuthuthukisa uhlelo lokusebenza, kodwa uma ungazi ukuthi ungaqala kuphi, ungakhathazeki – kunezinsiza eziningi ku-inthanethi zokukusiza. Ungafunda mayelana ne-Intent Systems, ShareActionProvider, kanye ne-OnItemLongClickListener. Maduze uzoba uchwepheshe we-Android futhi ukwazi ukwakha uhlelo lokusebenza oluhle ngokushesha! Qhubeka ufunda ukuze ufunde ukuthi ungaqala kanjani!
Izinhlelo zokusebenza ze-Android zingasebenzisa Amasistimu Wenhloso ukuxhumana phakathi kwezingxenye nemisebenzi. Izinhloso zingasethwa ukuze zicuphe izenzo noma umlayezo wokusakaza. Ungabhalisa emicimbini ukuze usabele kuyo. Ungacacisa idatha usebenzisa ama-URI nezinhlobo ze-MIME. Uhlobo lwedatha ofuna ukuyithumela kufanele luhambisane nezenzo ofuna ukuziqalisa kuhlelo lokusebenza. Izinhloso zingaqukatha idatha kanhlokweni kanye nedatha eyengeziwe esekelwe ekilasini lenqwaba, ongayithola nge-GetExtras() indlela.
Izinhloso zingasetshenziselwa ukubonisa izaziso zomsebenzisi, ubaxwayise ngezinguquko zesimo, noma wenze ezinye izenzo. Izinhloso zingaphinda ziqalise umsebenzi umsebenzisi angawenza kanye. Imisebenzi ingavalwa uma umsebenzisi efisa. Izinhloso zisebenza ngemuva futhi zizimele kumsebenzisi. Futhi zikuvumela ukuthi uthumele imilayezo uma ifayela selilungele ukusetshenziswa noma liyalandwa. Ukudala uhlelo lokusebenza lweselula usebenzisa i-Intent Systems kuyinqubo enzima kakhulu.
Ukuze udale uhlelo lokusebenza lwe-Android, uzodinga Isistimu Yenhloso ehambisanayo. Lokhu kuzokuvumela ukuthi udalule umsebenzi wohlelo lwakho lokusebenza kwezinye izinhlelo zokusebenza. Izinhloso ze-Android wumzamo wokuhlanganyela. Izinhloso ziyindlela enhle yokwenza uhlelo lwakho lokusebenza luqashelwe abasebenzisi bakho. Ngokungeza Inhloso kuphrojekthi yakho, uzobe usendleleni eya kuhlelo lokusebenza lwe-Android olungathokozelwa yiwo wonke umuntu. Inkundla ye-Android yenze izinhloso zaba lula kakhulu ukuzihlanganisa nezinye izinhlelo zokusebenza nokwenza ukushintsha phakathi kwezinhlelo zokusebenza kungabi nazihibe.
Uma uthuthukisa uhlelo lwakho lokusebenza, kufanele wazi izinhlobo ezahlukene zezinjongo nokuthi zisebenza kanjani. Ungasebenzisa lezi ukuze wenze ngokwezifiso uhlelo lwakho lokusebenza lwe-Android futhi udale okuqukethwe okusebenzisanayo. Ungakwazi futhi ukuhlobanisa Izinhloso nezinye izinhlelo zokusebenza, njengezaziso. Ungasebenzisa indlela efanayo ukuze uhlobanise Inhloso nolunye uhlelo lokusebenza. Izinhloso zingahlotshaniswa ne-CarAppExtenders ukuze kusetshenziswe kalula. Izinhloso zingasetshenziswa ezinhlelweni zokusebenza ukwazisa umsebenzisi ngesimo esiphuthumayo.
Izinhloso ziyizingxenye ezibalulekile zezinhlelo zokusebenza ze-Android. Inhloso yinto yedatha equkethe ulwazi mayelana nesenzo umsebenzisi afuna ukusithatha. Izinhloso zisetshenziswa ngezindlela eziningi, okuhlanganisa ukulandelela indawo, ukuzulazula, futhi nokuningi. Inhloso eyodwa ingaqala umsebenzi noma ingxenye yesiphequluli. Futhi isistimu ye-Android ingakwazi ukuhlonza izingxenye ezingasabela kunhloso. Kubalulekile futhi ukwazi ukuthi Izinjongo zisebenza kanjani nokuthi ungazisebenzisa kanjani ezinhlelweni zakho zokusebenza.
Uma Inhloso isithunyelwe, inkundla ye-Android izosebenzisa isihlungi senhloso. Idatha izonquma ukuthi iyiphi ingxenye eqalayo. Ngemva kwalokho umsebenzisi anganquma ukuthi iyiphi ingxenye afuna ukuyibona. Ungabhalisa izingxenye ezihlukene zemicimbi ethile nezihlungi zenhloso. Kungenjalo, ingxenye engenaso isihlungi senhloso izobizwa kuphela uma inhloso ebekela obala ikhishwa. Yilokhu lesi sahluko esikuchazayo. Uma ingxenye isibhalisiwe ngenhloso, kufanele icaciswe ngesenzo esifanele, uhlobo lwe-mime, kanye nemethadatha.
I-ShareActionProvider ye-Android iwuhlaka olunamandla olukuvumela ukuthi wabelane futhi wamukele idatha evela kwezinye izinhlelo zokusebenza ze-Android. Lolu hlaka luyingxenye ye-Android SDK futhi yethulwa ku-Android 4.0 (Izinga le-API 14). Ingahlanganiswa Kubha Yesenzo yohlelo lwakho lokusebenza lwe-Android. Ukuze ufunde kabanzi mayelana ne-ShareActionProvider, funda isifundo esilandelayo. Sizoxoxa ngezisekelo ze-ShareActionProvider ngokuningiliziwe.
I-ShareActionProvider yohlelo lokusebenza lwe-Android i-erstellen ingumhlinzeki wenkampani yangaphandle evumela onjiniyela ukuthi bahlanganise kalula nemithombo yedatha eyahlukahlukene.. Ungasebenzisa i-ShareActionProvider ukuze ukhiphe idatha emakethe futhi wakhe uhlelo lwakho lokusebenza lokutshala izimali. Uma usuwakhe uhlelo lwakho lokusebenza, ungabelana ngolwazi nezinye izinhlelo zokusebenza kudivayisi yakho. Ngokwesibonelo, uma ungathanda ukwabelana ngolwazi ekhasini lakho le-Facebook, ungakwazi ukushumeka isixhumanisi kuwebhusayithi ye-ShareActionProvider.
Esinye isici esiwusizo yikhono layo lokusingatha izenzo zabasebenzisi abaningi. Ngale ndlela, ungenza uhlelo lwakho lokusebenza lusebenzisane nakakhulu. Ngokusebenzisa i-ShareActionProvider, ungadala ulwazi lomsebenzisi olwenzelwe indlela abasebenzisi bakho abaluthanda ngayo. Futhi, nge-ShareActionProvider, ungase futhi usebenzise uhlelo lwakho lokusebenza lwe-Android ukuze uqoqe futhi wabelane ngolwazi. Ungakwazi nokuyisebenzisa ukuze uthole izaziso nezixwayiso mayelana nemilayezo emisha, futhi wenze abasebenzisi bakho bajabule ngesikhathi esifanayo.
Ungafunda zonke lezi zindlela ezithuthukisiwe esifundweni sokuthuthukisa uhlelo lokusebenza lwe-Android. Isifundo sihlanganisa 35 izifundo ezikuthatha isinyathelo ngesinyathelo ngokuthuthukiswa kohlelo lokusebenza lwe-Android. Iphinde ikufundise indlela yokudala i-database ye-SQLite app. Izokusiza futhi ukuthi wakhe izinhlelo zokusebenza ze-Android zezinye izinkundla. Uma usabambekile esigabeni sokuthuthukisa, ungakwazi njalo ukubhekisela esifundweni uma unemibuzo.
Ngaphezu kwalokho, ungasebenzisa i-ShareActionProvider kubha Yesenzo ukuze usebenzise isici se-UI esikuvumela ukuthi uhlukanise i-ActionBar.. Le nketho ingasetshenziswa Kubha yakho Yesenzo uma uhlelo lwakho lokusebenza lusebenza ku-Android 4.0 noma ngaphezulu. Ungafunda kabanzi mayelana ne-ShareActionProvider kugayidi Yebha Yesenzo. Kubalulekile ukuqaphela ukuthi lesi sici sitholakala kuphela ku-Android 4.0 nangaphezulu.
I-OnItemLongClickListeners iyizixhumanisi ezikhiqiza umsebenzi wokuphinda ushayele lapho into ichofozwa noma ikhethiwe.. Le ndlela ibiza i-OnItemLongClickListener ye-Android Framework ukuthi ibone lapho umsebenzisi achofoza noma ekhetha into ende.. I-Android Framework ibese ikwazisa okokufaka futhi ibonise isaziso esifushane se-popup kuyilapho umsebenzi wangempela ubonakala ngemuva..
Kufanele usebenzise i-OnItemClickListener-Interface ngaphambi kokuthi udale i-OnItemLongClickListeners-Instance. Lesi sixhumanisi siqinisekisa ukuthi i-onItemClick() indlela iyasetshenziswa. Izocelwa ngokuzenzakalelayo uhlaka lwe-Android uma kwenzeka umcimbi wokuchofoza isikhathi eside. Ukuze uthole imininingwane eyengeziwe, bheka isibonelo esingezansi. Le khodi ibonisa indlela yokusebenzisa i-OnItemLongClickListener kuhlelo lwakho lokusebenza lwe-Android.
Phakathi nengxenye engokoqobo yesifundo, sizosebenzisa i-OnItemClickListener. Sizobhalisa lesi sikhombimsebenzisi nge-ListView kuhlelo lwethu lokusebenza lwe-Android. Uma okufakiwe ohlwini kuchofozwa isikhathi eside, I-OnItemLongClickListener izohlola. Kubalulekile ukuqaphela ukuthi le ndlela ingasetshenziswa ngekilasi elingaziwa noma isigaba se-MainActivity.
Uma usubhalise isibonelo se-OnItemLongClickListeners, ungamisa i-ListView yakho ukuthi iphendule uma into esohlwini ichofozwa. Lokhu kuzoqalisa impendulo yokuchofoza isikhathi eside ku-AlertDialog. Kungumqondo omuhle futhi ukuba ne-ListView ephendula ukuchofoza okude. Ngale ndlela, abasebenzisi bakho bangafinyelela kalula kuhlelo lwakho lokusebenza ngaphandle kokuthi bashiye ukunethezeka kwekhaya labo.
Ngicela uqaphele, ukuthi sisebenzisa amakhukhi, ukuthuthukisa ukusetshenziswa kwale webhusayithi. Ngokuvakashela isayithi
ukusetshenziswa okwengeziwe, yamukela lawa makhukhi
Ungathola ulwazi olwengeziwe mayelana namakhukhi esimemezelweni sethu sokuvikela idatha