Khóa luận Tìm hiểu dịch vụ google map xây dụng ứng dụng chia sẻ vị trí với bạn bè trên nền tảng Android

BQ MAO DUC DAO T30 D3I HQC THANG LONG ---o0o--- ICHOA LUAN TOT NGHIEP TIM HIEU NCH VI) GOOGLE MAP XAY DIJSNG ffNG DIJNG CHIA SE VI TRi VOI BAN BE TREN NEN TANG ANDROID MAO VIEN HUONG DAN : Ths. Le Minh Tula SINN VIEN THVC EltN : Tan Trung MA SINK VIEN : A14986 CHUAN NGANH : Khoa hue may tinh HA NQI - 2014 MVC LVC LEI NOI DAU 1 CH1TONG 1. GIO.1 THI$U BAI TORN -3 1.1. VAI NET VE GOOGLEMAP 3 1.2. NNONo GI GOOGLEMAP KHONG HO TROT 3 1.3. Tim SAO LAI C

pdf115 trang | Chia sẻ: huong20 | Ngày: 07/01/2022 | Lượt xem: 356 | Lượt tải: 0download
Tóm tắt tài liệu Khóa luận Tìm hiểu dịch vụ google map xây dụng ứng dụng chia sẻ vị trí với bạn bè trên nền tảng Android, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
AN ONG DUNG CHIA SE VI lid? 3 1.4. MOI THONG HOAT %NG 4 1.4.1. Tai sao lai ding Android? 4 1.4.2. Google Map API la gi? 4 1.4.3. Server gamin 11 , hoot dong 4 CH1U'ONG 2. GIOI THI$U HE DIEU HANH ANDROID-----..------ ..... 2.1. ANDROID LA GI? 5 2.2. LjCH Sll PRAT TRIEN 6 2.2.1. Su ra dei cia Android 6 2.22. Ctic phien ban Android 7 2.3. KEEN TROC HE DIEU HANH ANDROID 11 2.3.1. Linux Kernel 11 2.3.2. Libraries 12 2.3.3. Android Runtime 12 2.3.4. Application Framework 13 2.3.5. Application 14 2.4. fiNG DUNG THEN TIBET BI ANDROID 14 2.4.1. 1VhOng gidi hpn cua thilt bi di Ong 14 2.4.2. Ngen ng9 lop trinh 14 2.4.3. Most truing hgp trinh 15 CHUVNG 3. TONG QUAN VE GOOGLE MAP API —16 3.1. GICsi THI$U VE GOOGLE MAP API 16 3.2. SO' DUNG GOGGLE MAP API 16 3.2.1. cai d4t va arch ery Google Map API 16 3.3. CAC DOI WONG QUAN THONG WONG GOOGLE MAP API 24 13.1. tuong ben db - The Map Object 24 3.3.2. Marker 24 13.3. !Info Windows 27 CHITONG 4. CHHONG TRINH 2FRIEND ...29 4.1. GI& Tilleu BA1 TOAN 29 4.2. MOT s0 flu cAu COA BA1 ToAN 30 4.3. CAc nitre NANG cHINN 31 4.3.1. Chic ming &mg kyStai !chain 32 4.3.2. Chtic :tong demo MO 36 4.13. Chic ming xem ban do 39 p 4.14. Chic ming xem vi tri mkt mink 42 4.15. Char ndng xem vi tri bon bi 46 4.3.6. Chile nang nip nh4t t4 tri 51 4.3. 7. Chtk mIng gui yiu cdu kit bon 53 4.3.8. Chic mkg xcic nIttrm yiu eau kit bon 57 4.3.9. Chtic ntIng tim ditimg din vi tri bon 61 4.3.10. Chile rating xem thong tin bon 63 4.3.11. Char ?tang giao tilp vol bon 66 4.112. Chic neng Miy kit bon. 69 4.3.13. Chic ming Op MO thong tin cli ?them 72 4.3.14. Chile :tang thay dal met khiu 76 4.3.15. Chic mIng (Yang mit 80 4.4. MQT SO VAN DE icHAc 82 4.4.1. Kin di chi duir• ng - Direction API 82 4.4.2. Kin di dinh vi vi tri thiit bj 85 4.4.3. Kin di idn suit cdp nhtit de lieu 88 4.5. THIET KE cO set al LIEU 4.11. M6 hinh quan hf 89 4.5.2. Cac bang ate !Nu 89 4.6. KET LUAN VA DINH WANG PHAT TRIEN 92 4.6.1. Kit qua dot &or 92 4.6.2. Dinh Throng phcit Men 92 CH1UONG 5. PHU LOC - CODE MQT So alit NANG CHINH• 94 5.1.1. Cher Wing deng kY tii khoint 94 5.11 Chtk ?tang ddng nhdp 95 5.1.3. Chic ming hien tri vi tri bon 96 5.1.4. Chile :tang gut yiu cdu kit km 97 5.1.5. Char ming xac nhtin yiu cdu kelt bon 98 5.1.6. Chtec Mug dinh vi vj tri 100 11.7. Char tiling tim dventg din vi tri 101 5.1.8. Chile ?tang cdp Mule thong tin ca thin 105 5.1.9. Char nang thay doi mot khtiu 108 TAI LIEU THAM !CHAO 110 DANII MVC HITNH ANH Hinh 2-1: Cac thanh phen cila he dieu himh Android 11 Hinh 2-2: M8 hinh hqp tac gifts may io Dalvik vi Native code 11 Hirsh 3-1: Android SDK Manager 16 Hinh 3-2: Cai det Google API 17 HInh 3-3: Cai Google API (tiep) 18 Hinh 3-4: Import thu vien 18 Hinh 3-5: Import thu vien (tiep) 19 HIM 3-6: Bet Google Maps Android API v2 20 Hinh 3-7: To API Key 20 Hin ► 3-8: Tao API Key 2 21 HIM 3-9: Tao API Key 3 21 Hinh 3-10: Tao project m6i 22 HInh 3-11: Them thu vien vio du an 23 H1nh 3-12: Infowindow thy Bien 28 HInh 4-1: Min hlnh kheri dOng 29 Hinh 4-2: Deng k, tai Ichoen med 35 Ifinh 4-3: Man hinh ding nhep 38 Hinh 4-4: Hien th1 ban de 41 HInh 4-5: Dinh v1 va hien th1 vi tri ngtrbi dung 45 Hinh 4-6: Xem vita ban be 50 Binh 4-7: Giri yeu eau ket ban 56 Minh 4-8: 'Chong the girl them yeu cku 56 Hinh 4-9: Xic nhen yeu ket ban 60 Hinh 4-10: Tim &Ong di den vj tri ban 62 Hinh 4-11: Xem thong tin ban 65 Binh 4-12: Giao tiep ved ban 68 Hinh 4-13: Hity kit ban (x6a ban) 71 Hinh 4-14: Cep fillet thong tin ca Mien 75 Hinh 4-15: Thay doi mat khan 79 Hinh 4-16: Dinh vi bang sling di dOng 86 DANH MVC BANG BLEU Bang 4-1: Cac each dinh vi vi tri 85 Bang 4-2: Bang Users 89 Bang 4-3: Bang Location 90 Bang 4-4: Bang Friendl 90 Bang 4-5: Bang Friend2 91 DANH MVC SO Del So de 4-1: So a Use - case 31 Sa do 4-2: Ding ky tai lchoan 32 So di). 4-3: Trish tkr Ding ky tai khan 33 So do 4-4: Ding Step 36 So do 4-5: Xem ban do 39 So d6 4-6: Xem vi tri cita minh 42 So do 4-7: Trish tv Xem vi tri cita minh 43 So d6 4-8: Xem vi tri bon be 47 So do 4-9: Trish tir Xem vi tri bon be 48 Scr do 4-10: Giri yeu citu ket bon 54 So de 4-11: Xac nhe ► yeu cam ket bon 58 So do 4-12: Giao flip veri bon 66 So de 4-13: Huy ket ban 69 Scr de 4-14: Thay doi thong tin ca nhhn 73 So de 4-15: Thay den met khau 77 So de 4-16: Ring xuat 80 So do 4-17: Ma hinh der lieu quan he 89 Lin NOIMu Sau met thai gian hoc tap va tim hieu clued sq turemg dart cua cac thay ca, em dA hoan thanh khOa Juan tot nghiep cua minh. Em xin than thanh gui led cam an den cac thay c8 giao b0 mon Tin hoc tru?mg Doi hoc ThAng Long dA huOng din va giOp der em trong qua With em hoc 6 twang. Em xin dac biet girl leri cam an den thay Le Minh Than dd htremg din em thuc hien Mt& luon bet nghiep. Sau khi holm thanh luan vim dm mink, em cam thay minh dA to tin han vai kien thi cda minh, tuy nhien em cam thay minh vin can rat nhieu thieu s6t can phai hoc tap de bel sung kien thiic. MOt lean nera em xin chin thanh cam an cac thiy co QA giup der em trong suet qua trinh em hoc tap 6 trutmg Doi hoc ThAng Long. Trong cuOc sting hien doi ngay nay, tong nghe phat trien math me gin') con ngtrei a clang thuc hien duqc Miring c8ng viec ma truerc day twang nhu rat kh6 Ichtin. Sr phat trien cua phuong tien giao thong gitip chang ta di co the bay cao has, di xa has va nhanh ham. Tut' ninon kid slat chin den met quec gia khac, met thanh phO Idkic hay don gian chi la met con phO lin du bon slat chin den, neu 'thong c6 ban da thi viec tim dubng se kha kh6 Ichtin. Thubng thi bon se phE vita di vira heti dubng, hoac tim met cira hang gin shat c6 ban ban do. Viec de cling Icha the vi, n6 se cho ban cam giac Icham pha met mien diet mai, tuy nhien n6 cling ton Idd nhieu thbi gian quY bau dm bon, nhat la neu ban la doanh titan dang c6 c8ng viec quan tong. D6 chinh la Mc ban can den su h8 trq ci5a Cling nghe thong tin. CEng nghe th8ng tin dA phat trien het sirc mash me trong nherng Mtn gin day. Ngay nay bon c6 the tre chuyen, chia se hInh anh vai nhOng ngutri bon, ngueri than trong gia dlnh 6 Ichoang cach nua vemg trai slat hay xa ham nera, giteg nhu ban dang tr6 chuyen vai mot ngued a ngay wit minh vay. CO the nal ding nghe phi trien dA dem con ngutri lei gin nhau has. KhOng chi c6 vay, cac chuang trinh ling dung dm Cling nghe thong tin con el, con ngtred c6 cuOc sting a dimg has. Kh8ng can bit dean vet s6 sach nhu truac, hien nay tat ca dA 6 the luu tren may vi tinh veri met thiet bj luu ter vo cling nhet gm. Han the 'Oa vai met s6 chuong trinh dit tien, chung ta con duqc h8 trq ca viec hooch djnh phuang huerng phat trien cho doanh nghiep. fly can yen de di neu 6 tren? Lieu CEng nghe th8ng tin c6 gulp gi thing ta tong viec tim dubng di lei khi den met not ma ta Ich8ng bier? KhOng phai Mc nao ta cling mang theo Laptop hay may vi fish, viec di chuyen you ciu ta mang theo thiet bj she gon. D6 chinh la met ling ch,mg cfm chuong trinh ban do tren thiet bj di dOng thong mirth. Thiet bj di dOng thong mirth khong can qua xa lo vai chimg ta. D6 chinh la Dien thoai th8ng mirth — Smartphone — hay may tinh bang — Tablet. NhOng thiet bj di dOng de c6 kich thuerc cling nhu tong luqng rho han nhieu so vai mot chiec Laptop. Giao 1 dien de clang sir dung han, Chao tic bing cam Ong tien lqi han va khong phi thuec vito cac thiet bj di kern Ichac. Han the ars, thief bj di Ong sir dung nen tang phi bien nhu Android, IOS sb hau met kho img dung kiting 16. Chic hin ban dang to hei ring vei kho img dung len nhir vay thl chic chin se c6 Stung img dkuig kern chat lugng, hay cen gqi la "rac", veay lam sao met ngued dung birth thtrbng c6 the phan biet duqc? Cau tra lbi la ban hay yen Lim ve chat Itrqng ciut kho Ong dung Android hay LOS. Bei vi di c6 met (lei ngil uy tin giep to kiem duyet Ong dung truck khi duqc dua len kho Ong ch,mg chung. Han the nem dii v6i met nen tang ce nhieu ngubi sir dung ban dm duqc h6 trq bei chinh nhibig ngtroi dimg truer de. DO chinh la sue manh cea ceng ding ding ngh'e. Tref lai ved yin de chink, ling dung nao glop db to tiet kiem thbi gian tong vies tim dubng? D6 chinh la CEng dung ban d6 tren diet bj di dung. Hien nay met chiec dien thoai thong minh ma kh8ng ce chuang trinh ban d6 thi khe ce the gqi la "thong minh". Hoic vi met 19 do nao Q6 nha sin xuit luqc bet img dung de, thi viec tien ngueri ding lam khi se tau met chiec dign thoai th8ng minh de la tai img dung ban d6. O phan sau t8i se de cap den met ling dung ban di rat phi bien, c6 the nOi la t6t Mat hien hay, de chinh la GoogleMap. Chinh nhUng nhting 19 do tren da tao Ong luc cho em tim hieu va xay dung img dung chia se vi tri tren nen tang Android sir dung ban di Google Map. Chi tiet ye du an nay em se With bay b nhemg phlin sau. Chuang 1: Geri thieu bai toan Chuang 2: Gioi thieu he dieu lulnh Android Chuang 3: Ting quan ve GoogleMap API Chuang 4: Chuang With 2Friend Chuang 5: Phu lye: Code met s6 chi= Ming chinh Tii lieu tham 2 CHVONG 1. Glen THISU BAI TORN 1.1. Vai net ve GoogleMap Nhu citing ta da biet, bit chip suy thoai kinh te, nganh ding nghe thong tin van dang phat trien v6i mot toe dg cheng m$t. Trong thbi gian gin day danh diu sy phat trien rat manh cua cac thiet bj dien thoai thong mirth (Smartphone). MOt trong nhung (mg dung quart tong nhAt va co the nal la "khan the thieu" d6 chinh la ang dung ban db. Ban d6 GoogleMap duqc xay dung ben ceng ty Google bang the hinh anh vg tinh va viec di tim hieu throng ph6 thuc te. C6 mot so than vien cfra Google duqc tra ltrang cao voi c8ng viec dap xe dap c6 gin thiet bj cita Google de ghi lai va chyp anh dutmg ph6. Cong viec nay ton rat nhieu thbi gian, nhung nha d6 ma ban d6 GoogleMap co dO chinh xac rat cao va nhOt fit thutmg xuyen. ling dung Maps hay chinh la GoogleMap gulp ngutri dung c6 the sir dung ban d6 nay trong viec tim duang di. 6 phart sau toi se gieri thieu ky han ve ung dung thy. 1.2. Nhftng gl GoogleMap khong ht) trq? DOng hanh v6i su phat trien cfut ding nghe, new nay each con ngubi giao tiep cling di kit di. ChAng ta khong chi chia se hinh anh, loi nei, van ban ma yeti thiet bj di dOng thong mirth ta con c6 the chia se ca vi tri ciut mink. Cac thiet bj di dOng thong mirth hau het deu tich hqp tinh nang GPS — gitip djnh vi Nei tri sir dung tin hieu vg tinh. Ngoai cac eh& nang co ban ma GoogleMap da cung cap nhtr tim dtrimg, chi dutmg, dieu huang... co mot chirc nang quan trong khac ma GoogleMap da dimg trq da la firth nang chia se vi tri vUi ban be, ngutri than(Google Latitude). Chinh dieu nay da thitc dAy ten xay dung mot (mg dung chia se vj tri ban be teen Google Map. 1.3. Tai sao lqi cAn ting dyng chia se vj tri? Nhu ta da thAy, co se dft lieu de luu aft da lieu ban d6 ctia ca the giOi la rat 1611, hay c6 the not la v8 cling lon. Chic chin khong the nao luu trtt tit ca cac dia diem, cac nha hang, dja danh tren ban d6 duqc. Cho du Google co co ging lam dieu do thi dft lieu se khong the cOp nhOt thu?mg xuyen, trir khi moi khu ph6 tren the giei deu co than vien cita Google. Chinh vi v$y thing ta co the S thanh mot ngtrtri clang tot bung, bang each giam di ganh n$ng rill* dja diem cho Google. Chang ta c6 the to cop nhOt vi tri cilia minh. Tuy nhien, khong phiti bit tit ai, bit cir lac nao ta cling mutin chia se vj tri cfta minh. Doi khi ta chi mut% chia se yen ngutri than trong gia dinh, hay bon be ma then... Con nhieu van de !chic nfta, nhung da chinh la ljf do de WI xay dung chuong trinh nay. 3 1.4. Mei truirng boat (long Chuang trinh nay se &gm xay dvng tren he dieu hanh Android — MOt nen dang phat trien rat manh tren cac thiet bj di dOng — vi sir dtmg Google Map API. 1.4.1. Tgi sao ding Android? Android la mOt hg dieu hanh ma nguan ma, chlnh vi the nen ne duqc phit trien rat da dang theo nhieu hue ng khic nhau. ChInh dieu da da &rip cho cac nhi sin xuAt thiet bi di ding a clang hon tong viec cho ra nhUng sin pham het sirc da ding, gifip Android c6 s6 ngteri sir dyng kh6ng 16. Ben milt 46 gii thanh mOt thiet bi Android ding re hon thiet bj chay IOS hay Window phone ma firth ruing yin kitting he thua kern. 1.4.2. Google Map API la gi? Google Map API li mOt Giao dien 1#p trinh img clang do Google cung cap. NO glop cho lap trinh vien c6 the sir citing chinh bin d6 cua Google de xay citing img dung cila mirth. Tuy nhien khong phii tat ca the firth rang cua Google Map day di dau duce cung at) a day, chinh vi the ngubi 18p trinh vien phii tim each sir clang th$t Idiot) leo de giai quyet cac van de bii toin (tat ra. Chi tiet ve Google Map API se duct de Op a pitan sau. 1.4.3. Server qudn ly hogt Ong M#c da Google Map API cung cap cho to mOt ban dO tuong d61 hoin chink, nhung da chi li img dtmg ben phut ngubi dung. De ling Mpg c6 the hoat ding can c6 mOt Server. Server nay c6 nhiem và luu thong tin tai khoin cua ngubi dimg, luu v1 tri ngubi dimg vi thvc hien mOt so chirc niing khic. Server nay can ducm via bang mOt non net ph6 bien vi khong phv thuOc vio hg dieu birth, da chinh la nein ngft Java. Server khong an c6 giao dien 46 hoa, chi co nhiem vv nh#rt yeu tau tir phia thiet bj kith, zir ly vi tri ve ket qui. Tuy nhien, da la ding viec cim ngu&i 1#p trinh, ngubi sir clang img citing nay khong an quan tam server lam gi ma chi can thao tic tren thiet bj dm mirth. 4 CHUONG 2. GIefITHIEU a DIEU HANH ANDROID 2.1. Android la gi? Android la melt Hg dieu !Anti dinh cho cac thiet bj di dOng nhu dien thoai thong minh hay may tinh bang. Android duqc xay dung Iron nen tang Linux va sir dung nem ng0 Java. Ban du, Android duqc phat trien boi TOng cong ty Android vii str ho trq tai chinh cua Google. VI° Min 2005, Google di chinh that mua lai ding ty nay. Tuy nhien vao theri diem da Android van chug duct ra met. Den aim 2007 Android mai ra mit cling yeti tuyen b6 thanh lip Lien minh thiet bj elm tay ma: mOt hiep hOi g6m cac ding ty phan mem, phAn ming va vien th8ng yeti mac tieu day math cac tieu chuan ma cho cac thiet bi di dOng. Thief bj du tier chug Android duqc ban ra thing 10 mitn 2008. Android la he dieu hanh c6 ma nguln ma va Google phat hanh ml nguln theo gily phip Apache — mOt giay phep kW:Mg c6 nhieu rang butjc. Chinh dieu nay di glop cho cac nha san xuet thiet bj, mpg di dOng va cat lelp trinh vien duqc dieu chinh va phan phOi Android mOt cach tar do. Tinh den thed diem thing 10 niun 2012 — 4 Titan sau khi thiet bj Android du tien duqc cong b6, di ce khoing 700.000 img dung tren Android, va s6 luqt tai ting dung tree elm hang 'ring dung Google Play &cc tinh khoang 25 ti luqt. Chinh nhUng uu the nhu v1y ma Android di fret that nen tang dien thoai di dOng thong minh phO bier nhit the gi6i, vtrqt qua Symbian vao quy bOn nim 2010. Android duqc cac c8ng ty c8ng nghe sir dung khi h9 an mOt hg dieu Minh khong mItng ne, c6 kha ning tinh chinh va gia thenh r8 chay tren cac thiet bj cong nghe cao. Ket qua la mic du duqc thiet ke de chay tren then thoai, may tinh bang, Android di xuit hien tren nhieu thiet bj khac nhu TV, may chai game va nhieu thiet bj 'chic. Tinh den tit diem quy ba nam 2012, Android di chiem den 75% thj phlin dien thoai thong minh tren town the giai. CO tong cong 500 trieu thiet bj di &Km kich hos va 1,3 trieu luqt kich host moi ngay. St; thanh c8ng cim hg dieu hanh nay cling Man ne frac thanh muc tieu trong the Ai hen lien quan den bAng phat minh, hay can gui la "cuOc chien dien thoai thong rninh" gift cac c8ng ty ding nghe. 5 2.2. Lich sir phit tries 2.2.1. Sy! ra del cues Android Tang Gang ty Android (Android, Inc.) duqc thanh lap tai Palo Alto, California vao thing 10 nAm 2003 beri Andy Rubin (thing sang lap ding ty Danger), Rich Miner (clang sang lap Tang cong ty Vien thong Wildfire), Nick Sear (timg 11 PM giam doc T-Mobile), va Chris White (truing thiet ke va giao dien tai WebTV) de phat trier, theo to i cita Rubin, "cic thiet bi di &mg thong minh han c6 the biet duqc vi tri va se( thich cita ngubi dimg". DV nhang ngutri thanh lap vi shin vien deu la 'tang ngubi c6 tieng am, Tang cong ty Android boat dOng met each Am thim, chi tiet 10 r&ng hq dang lam phan mem (lath cho din thoai di dOng. Trong nAm do, Rubin het kinh phi. Steve Perlman, mOt ngubi ban than cita Rubin, mang cho Cog 10.000 USD tien mat nhtmg tit ch .& tham gia vao cong ty. Tang cong ty Android duqc Google mua lai vao ngay 17 thing 8 nAm 2005, bien n6 thanh met be phan trvc thutic Google. Sau thucmg vv nay, nliimg nhan vien chit chat dm Tang cong ty Android An tiep tic a lai cong ty lam viec. Vao thbi diem da kitting c6 nhieu th8ng tin ve cong ty Android, nhtmg dA co nhang loci clan rang Goolge dir tinh tham gia thi trutmg thiet bi di dung sau buem di nay. Tai Google, them do Rubin dung du dA phat triers met nen tang thiet bi di dOng tren nen nhan Linux. Google quing bi nen tang nay cho the nha sin xuid dien thoai va cac mang vien thong ding 16i him se cung cep mOt he thong linh hoot va c6 !chi nang Wang cap. Google dA lien he vii hang loaf hang phan cling ding nhu dai tic phan mem. Ngay 5 thing 11 nAm 2007, lien minh thiet bi cam tay ma, hay con gqi la Open Handset Alliance, met hiep Mit gem nhieu cling ty trong de c6 Texas Instrusments, tap doan Broadcom, Google, HTC, Intel, LG, tap doan Marvell Technology, Motorola, Nvidia, Qualcom, Samsung Electronics, Sprint Nextel va T-Mobile duqc thanh lap shim mac Bich phat tries cac tieu chuAn ma cho thiet bi di Ong. Cling chinh thbi diem de, Android cling duqc ra mit yeti vai tr6 la san phatt n Mu tien ciza Lien minh. Chiec di'en thoai chay Android du tien duqc ban ra la HTC Dream, chay tren nen tang nhAn Linux phien ban 2.6, phat hanh ngay 22 thing 10 aim 2008. Su trtmg cita Android la met con Robot mau xanh la coy do hang thiet ke Irina Blok tai California ye. 6 2.2.2. Cdc Alen bdn Android a. Android 1.0 Ra mat: 23 thing 11 nom 2008. Android 1.0 rat nguyen sa, tich hap sin khi rang deng bO der lieu yeti cac djch vu trqc tuy'en aim Google nhu Gmail, Google Calendar va Contacts, mot trinh phat media, hit trq Wi-Fi va Bluetooth, thanh tang thai hien thi cac thong bao img dung va mot img dung chap anh (camera) tuy chua cho phip thay doi dt) phan giai va chat luqng anh nhu cac thiet bi ngay nay. HTC Dream la don smartphone thucmg mai ding Android du tien v6i kieu Bang tract kem ban phim vet lg. Phien ban Android 1.0 chua duqc Google ct(ft ten, do truck 46 ten g9i Astro Boy hay Bender. b. Android 1.1 Ra mat: 9 dying 2 nom 2009. Ben quilt so phien bitn, Google da bit diu dua he thong ten g9i vio cac phien ban Android. Tuy chua chinh thirc itp dung nhtmg Android 1.1 da c6 ten Petit Four. Kitting bao gem nhieu tinh rang, phien ban nay be sung mitt so chirc ming meri cho Google Maps Men thi chi tier hart, ban phim a° g9i dien thoai da c6 the hien thi hoc An Mil gqi, chucmg trinh SMS cho OCT ngubi dung luu tap tin dish kern. Android 1.1 sirs mot s6 loi trong Android 1.0. c. Android 1.5 Cupcake Ra mitt: 30 thing 4 !Am 2009. Cupcake, ten diu tien ip dung cho phien ban Android. Cupcake mang nhieu tinh nang meri nhu ban phim io c6 kha Wing chr loan tir dang go, tir dien tir nger do ngutti dung at ra, ho trq widget tren man hinh chink, quay phim va phat lai video clip, luqc sir then gian cuOc goi, the 40 to d'Ong xoay man hinh theo hueing sir dung (screen rotation). TrInh duy'e't web trong Cupcake c6 them kha nang sao chop va dan. Ngoii ra, phien ban nay cho phep ngutti dimg hien tit hinh brill trong danh ba, mot diem thu vi ma hku het ngtroi dimg dien thoai di dOng muon c6. Man hinh chuyen tei va hinh anh khi khoi 4Ong may duqc lam m6i. d. Android 1.6 Donut Ra mat: 30 thing 9 nam 2009 Donut nang cap cac chirc nang trong phien ban Cupcake, met Ong chirc rang tim kiem bing giqng n6i va ky to den bookmark va danh ba. Android Market tit thanh kho img dung chinh de nguiti &mg tim kiem va xem cac img dung Android. !ling dung 7 chyp anh va quay phim trong Donut nhanh hen. Hg dieu birth ho trq man hinh cep 40 phan giai 16n ham, huOng den clic the hg smartphone min hinh km. e. Android 2.0 Eclair Ra mat: 26 thing 10 nam 2009. Chi sau gin mOt than ra mat Donut (Android 1.6), Google tung ra Eclair, phien ban dugc nhan djnh la buck di len dm he dien hinh nay. Eclair c6 rat nhieu chi tien, tit giao dien den (mg dung ben trong he' thOng. Ung dyng chyp anh tang cubng them chitc nang zoom (phang to), can bang trAng, ha trq den flash va cac hieu img mau sic. He th0ng hoat dOng On djnh hen, cal thien kha nang xit 1Y, hi5 tug ket not Bluetooth tot hen, dac biet thy chcon ding hi) nhieu tai 'Moan. Met diem thuan tien dugc danh gia cao lac bay gib la giao dien danh ba cho phep nhan chgn vac' mOt anh danh ba de g9i, nhan tin hay email den hq. Giao dien img dyng Lich bleu (Calendar) cung dugc thay dOi. Eclair IA phien ban Android du tien ha trq anh nen dOng (live wallpaper). Tuy nhien thy chqn nay tieu ten kha nhieu pin vi titi nguyen may. f. Android 2.2 Froyo Ra mat: 20 thing 5 nam 2010. Tir phien bin 2.0 tro di, Android &I din hoan thien hen. Phie'n bitn 2.2 (Froyo) duce tich hqp Adobe Flash, keo theo hang lottt img dyng va game. ND:raj dung ding c6 the xem video clip nen Flash nhu YouTube va "ra lenh" thyc hien cube goi qua ket net Bluetooth. MOt chic nang mai trong Froyo dugc them ngubi dimg luu dOng yeu thich IA USB Tethering va Wi-Fi Hotspot, thin chiec smartphone Android thanh thiet bj phat sang Wi-Fi to ket net 3G. Tinh tiling nay dugc sit dyng rat phi) hien den ngay nay. Len diu tien Android cho phep chi dat img dyng (app) len the nher SD thay vi mac djnh chi ngay vac' b0 nher trong cita diet bj. MOt chitc nang mei cita Froyo do la mat khau di ha trq se va chit se. Thiet bj du den mang nhan Froyo ra mat thj trubng la HTC Nexus One. g. Android 2.3 Gingerbread Ra mat: 6 thing 12 nam 2010. Den cuOi am 2012, Gingerbread yin dang duce sit dung eon rat nhieu thiet bj dimg Android, chiem den hen mOt nira (54%). Google hqp tic Samsung trinh lang dong smartphone diu tien sit dyng Gingerbread mang ten Nexus S, ha trq cong nghe giao tiep tam gin NFC. 8 Gingerbread dua vao he th6ng met ceng oar quart 15r tai tip tin, cho phep theo dei va truy xuit den cac tip tin da tai ye may. He thong nay hiS trq nhieu camera cho cac thiet bj c6 camera mit sau va trtrac, quan 15r nguton pin hieu qua han, fiat kiem thin ltrang pin. Phien ban nay khic phuc !chi nhieu loi tir Froyo, kern theo met so dieu chinh trong giao dien ngtroi dung. h. Android 3.0 Honeycomb Ra mot: 22 thing 2 nrun 2011. Day Hiring chi la met phi'en ban, ma ce the xem la met the he Android du tien anti rieng cho may tinh bang (tablet), ra mot cling tablet Motorola XOOM. Mang nhemg firth nang tir the he Android 2.; Android 3.0 cal tien giao dien phit hqp veri each sir dung may tinh bang, ban phim ao than alien han, h8 trq xir 13 , da the vu (multi-tasking), cho phdp chuyen doi qua lei cac ling dung dang cling chay. Kherng chi c6 be mit dirge trau chu6t, phin lei he then c6 the cal tien ttrcmg thich yeti plan ding nhu hO trq chip xir ljr (CPU) da I8i, tang toe plan ding... Android 3.0 dit nen meng quan trong cho the he Android 4.x hqp nhAt, 'chic phuc stir phan mang cila Android (c6 cac phien ban rieng danh cho smartphone vi tablet). i. Android 4.0 Ice Cream Sandwich Ra mot: 19 thing 10 nam 2011. "Ice Cream Sandwich" (ICS) la the he Android dirge mong dqi nhit den nay, ra dtri ding ding smartphone bom ten Samsung Galaxy Nexus, the hg smartphone diu ten sir dung ICS. Android 4.0 dua chirc nang truy xuat nhanh cac ling dung thutmg dung vao phir' ben duOi giao dien chit, thy bien widget, a sip xep vi duyet danh sach ung dung hon. Cac img dung a c6 the truy xuit nhanh tir man hinh khOa thiet bi (Lock screen), vao thtri diem d6 cac hang san xuAt thiet bj chi mai cho phep Camera ce the chan nhanh tir Lock screen. Ice Cream Sandwich host dOng muqt ma, nhanh va dpp han cac phial ban fru& d6. j. Android 4.1 Jelly Bean Ra mit: 9 thing 7 nam 2012. May tinh bang Nexus 7, san phim hqp the gins Google va Asus, lit thiet bj diu tien sir dung Jelly Bean. Android 4.1 'Ling dm hog dOng cho he dieu hanh dua Google, tit thenh he dieu hanh cho thiet bj di dOng hang diu hien nay, de daa ca "8ng lan" Windows. KM ring sip xep giao dien chit va widget tong Jelly Bean c6 !dui nang thy bien cao va rat linh hoot. He thong hO trq dich vu vi dien to Google Wallet, dic biet trinh 9 duyet web mac djnh trong Android duqc thay the bt5i dai dien ten tan: Chrome, yeti kha neng dOng ba du lieu theo tai khoin vai ban Google Chrome tren may tinh. k. Android 4.2 Jelly Bean Ra mat: 29 thang 10 nem 2012. Chi sau gen nem thang ra mat Android 4.1, Google nep tyc tang cep cho Android vii phien ban 4.2 va vin mang ten Jelly Bean. Android 4.2 tiep tpc mang den nhfing cai tien hap din cho (mg ch,mg chop inh (Camera) Sur HDR, Photo Sphere, hieu (mg link Google Now, dua tinh nen luta chqn to rat hay trong ban phim so. Chirc rang ho trq nhieu tai Idioan ngutri dimg Ian dau tien duqc ap thing trong Android 4.2 nhung chi c6 ngutti den may tinh bang thin huerng chile rang nay. 1. Android 4.3 Jelly Bean Ra tat: 24 than 7 nem 2013. Android 4.3 Iii la mot fling cep non cua phien ban mang ten Jelly Bean. Phi'en ban nay hi) them tinh nang Bluetooth rang luqng thip, OpenGL ES 3.0, tit) , chqn Wifi luSn bat, hi trq ngon ngit doe tit phai sang trai... Vii phien ban dui ba mang ten Jelly Bean, Android dang din hoan thien han, yeti nheng tinh neng mai, Android hila hen se thu but nhieu ngay cang ngutri sit dung. m. Android 4.4 KitKat Ra mat: 31 thing 10 nem 2013. Mac du rat nhieu nguiti de do doin phien ban Android mei c6 ten gqi "Key Lime Pie" trong suOt mot thei gian dai, Google de cho ra mat phien ban 4.4 vii ten gqi KitKat. Android 4.4 KitKat bao gem rat nhieu ruing cap trong he thOng va (mg ch,mg, nhung diem net bat that ciia phien ban nay de la he try cac thiet bj co cau firth that) hot. KitKat yeu eau be the tei thieu (RAM) chi la 512 MB, giiip cho cac thiet bj cAu hinh thep c6 the thing cap va trai nghiem mot cach a clang. 10 Applications Famework to chuc Ling Liumi Libraries IH;1 Android Runtime (Thai 'Tan chay Ar droith Applications l Linux Kernel '. time Android SDK apps Anima(' NDK apps 241 Android app framework Standard libraries 2.3. Kien true 14 diet' birth Android HIM 2-1: Ctic think pkin csia kf dl kink Android 2.3.L Lima Kernel DOi vei nhCmg phien ban truer, Android duct xay dung teen 130 than Linux 2.6 cho nheng djch vg cot lei nhu security, memory management, process management, network stack, driver model. BO than nay lam tillitm vu nhu mOt lap trung gian ktt not pith' ring thiet bj ya phan *rig dung. Mink 2-2: M6 kink kw tic gilta may do Dalvik vi Native code JNI: Java Native Interface (Tuang ty Ichai nitm Application Programming Interface) la mOt 13 .0 framework cho phi!) ma lOnh vitt bang Java chay ten may ao java 11 c6 the goi hoc duqc gqi boi met ung dung viet bing native code ((m g dung duqc viet cho met phAn ding cu the va tren met he dieu !faith cu the) !mac nhUng be thu vien viet bing C, C++ hoc Assembly. Bang cfich sir dung NI, Android cho ph6p cac ling dung chay tren may ao Dalvik c6 the sir dung nhfing phucmg thirc ductc viet bang cac ng6n ngft cep thAp nhu: C, C++, Assembly. Qua de cac nha phat trien ling dung ca the xay dung ling dung dua ten cac be thu vien viet bing C, C++, Assembly 'them tang Mc de thuc thi cim ling dung hoc sir dung ntrang firth nang mirc thep ma non ngft Java Ichong hie trq. Tuy nhien ngtrai phat trien ling dung an phai can nhac su gia tang de phirc 4p cim ling dung khi quyet djnh sir (king cac be thu vien nay. 2.3.2. Libraries Day la be cac thu vien xay dung nen cac chirc nang chinh dm Android System C library: Day la tOp cac thu vien he thong. Thu vien nay duqc viet bang ngon ngft C, C++ chuen c6 the pi duqc thong qua giao dien Java Media FrameWork: Day la be thu vien h6 trq trinh dien va ghi cac djnh dung am thanh, hinh anh phe bien. Surface manager: Quan ly hien thj nei dung 2D va 3D. Cho ph6p tvo cac ciza so giao OpenGL: HO trq xay dung ling clung de hqa 2D va 3D. - SSL: Cung cap chile nang bao inOt cho fiat bi SGL: Engine he trq M hqa 2D. Free Type: HO trq cac Font Bitmap va vector SQLite: Met co sir du lieu nhe gqn va mph me. Cung cep be may co s6 du lieu duqc nhimg trong thiet bj. Webkit: Ho trq hien thj nei dung website. 2.3.3. Android Runtime He dieu hanh Android tich hqp sin met top hqp the thu vien cot 16i, cung cep heu het cac chirc rang. Mqi ling dung ciut Android chay tren met tien trinh cua rieng n6 cling v6i met the hien cim may ao Dalvik. May ao Dalvik thuc to la met bien the dm may ao Java duqc sira Mi, be sung cac cling nghe dOc tnrng cim thiet bi di Mug. NO duqc xay dung veri intic dich lam cho cac thiet bj di (king c6 the chay nhieu may k met cach hieu qua. Tnrem khi chay, mei ling dung Android deli duqc convert thanh file thuc thi Arai QM dm nen Dalvik Executable (.dex). Dinh long nay duqc thiet ke de phi hqp veri 12 cac thiet bj han the ve b0 :the sung nhu toe do xi 1),. Ngoai chic flan ke tren, may lo...i ding ky that bai - Neu ten dang nh#p chua ten tai, Server nen hanh them man ban ghi vao co ser dli lieu. Cac bang sau se dtrqc cap nhot: 3 Bing users: Them ban ghi mai vai ck thong tin sau: o Login: Ten clang nhalp cua ngubi dung o Pass: Mat khau dim nhap o Name: Ten that dm ngubi dung o Phone: SO dien thotti cita ngutri dung o Status: Trang thai ding nhap, mac dinh lit 0 3 Bing Location: Tqa deo vi tri colt ngubi dung, gia tri mac dinh la (0,0) - Sau khi them ban ghi thrinh c8ng, server tien berth Ira ket qui thong bio viec ding kj, thanh c8ng cho client. Oic yen an d$c bift Ichic Thiet bi can duce ket nal mpg de tien hinh giao flip vet Server Giso difn mini' boa fiur1(1 hi Ten dang nh#p M#t khiu Ten day & 56 dien thoai 1r lr ti Hind 4-2: Ddng # Ili Moan Mai 35 4.3.2. Chits Wing ddng nhap UC #0002 HANG NH.411 Del phut tap: 1 M0 ti Chic 'tang nay cho phi!) ngueri ding nhop ten tai khoan va mat khau de truy cap vao h0 thong. Neu ngu&i ding chua ci Si khan thi can ding kt tai khoin. Chit fling ding ky se duqc de cap 6 phin sau. Ngtreri ding can phai ding WM meri c6 the sir ding sac chic ;tang khac cia chuong trinh. Tic nhin Chfnh Ngueri sir clang Thy KhOng do Tien dieu Idea Ngueri sir dung can t co tai ;Moan de ding nh#p Hill diets Min Thinh cling Ngueri ding truy cap duqc vao giao dien chinh dm chtrtmg trinh Nguari dung Icheng troy clip duqc vao he thong, trang thai tai Idtoan ngueri dung idling thay del. So' 66 luong song viec so 66 tubas cans !MK: Chat alto ding nhaLl yva clOnis Tait W Android Dich vy cSa Gaffe 3 Co at sICP OW —el. OM *Ms dwn nth 00111•060 I ca..-Men •••• A b us MS 0 ar So die Se SS alt i. Se d.at Cl••••• on So ii_o/ / wow T.4"..7• / I -1°1 dionames dim c- .wax ) Se Si 4-4: Haag nkfp 36 Phtro'ng phip thyr hien Ngirivi sir dying Chuang trinh se hien giao dien de nguai clUng nhep tai Ithoin va met khan. Sau khi hoin thinh thao tic nay, ngueri dung se barn vac) nut "Ding nhep" ho#c "Login". Lac nay ngueri dung chi can cho chucmg frith phin hOi lai. Neu ding nhep Minh clang, chucmg trinh se cho phip ngued dung sir dung cac chirc nang tiep theo cita he thOng. Chuang trinh xir It Sau khi ngu&i dung nhep th8ng tin can thiet vi bign nut thing nhep, chucmg trill!' se thuc hien cfic cong viec sau: - Lay ra gia trj ten ding nhep va met !chin cita ngueri dung - Ma hea met khau bang hiun ham MD5 - Deng gai ten ding nhep va met khau thanh dung: login - thii clang lenh 6 tren den server - Cho dqi server phin hOi va tra ket qua ve cho ngueri dung. Neu ding nhep that boi chtrang trinh se hien MI th8ng bio kim theo 161 guly ra. Neu ding nhep thinh cling chucmg trinh se chuyen den chirc nang deep theo. Server Server se ling nghe yeu au tir phia client. Yeu au ding nhep S phia client se co dinh dung: login Sau khi nhen dien duqc mesh lenh ding nh#p ciut client, server se thuc hien c8ng viec sau: - Kiem tra ten ding nhep: server se tien hinh truy cep vao ca set dfir lieu va tim xem ten ding rthep ngueri dung da nhep vio c6 !chop vii di khoin nao hay Idthng. Neu !thong tan tai ten ding nhep thi server se thong boa cho client la ding nh cip killing thanh Gang. - Sau tim duct usemame kherp vii ten ding nhep ngueri dung da nhep vio, server se tier hanh lay ra met 'Mau dm tai Ithoin do. Luu jr met khgiu ma client giri den server kh6ng phiti la met khan ma ngueri thing nhep viva. DO la met khau da duqc ma heut bang ham barn mOt chieu. Chinh vi the met khau cita cac tai khoin duqc km tren ca so clh lieu chinh IA ma barn dm met khau thet. VI Vey chinh nguen quan trj he thOng cling !thong biet duqc met khau dm ngueri dimg. Sau khi lay ra met khau S ca so der lieu, chucmg trinh server se e'en hint' so sinh vii met khan da nhen to client. Neu van khop nhau thi se tra ve ket qua ding nhep Minh cong, ngtrqc loi se tra ve ket qui ding nhep thit bal. Cic yin an d$c bit khic Ur phien bin Android 4.0.4 tret di, phan ket nei Socket can pith d#t vio trong Asyntask meri c6 the choy &me. Neu thong chuong Atilt se bi Force close. 37 Giao On minh hos Binh 4-3: Man kink ding nkQp 38 4.3.3. Chat nang xem ban da UC #0003 XEM BAN DO DO phirc tip: 1 M8 ti Sau IN ngtrin dung dang nh$p thanh ding, chtrcmg trinh se hien thj man hinh chinh cila chuong trinh. Chuang trinh sir dung Google Map API a hien thi ban di. Bin di nay gin nhu hob town giOng vei ban di GoogleMap chuin. Nguei dimg c6 the thao tic vei ban di nhu chuyen vi tri bing Ice° tha, thu pheng. Man hinh nay la man hlnh chinh va quan tong nhit ctia chi:mg trinh. TO day ngtrai dung c6 the sir dung clic chirc Ming tiep theo nhu them Nut, tim duang den vi tri bon... Cac chtic nling nay se duqc de cop 6 plan dip theo ciut tai lieu Tic nhan Chinh Ngwei sir dung Phy Google API Tan diiu Idin Google Service phiti hoot dung I dit kien Thinh (tug Ban di dtrqc hien thi Lei Ban di Iching duqc hien thj Se do iubng ding viiic Soda lubng ding viec:Chin ring lib dil bin db 64girbi dung O1hiit bl Android pith " did 600gle Server 9 Ca salt Nu Luau y—otrytagribins —40 11411tiviilt ode Ilsotkidbinta 4--- tnt Otla / lit CIPINthimlb Se di 4-5: Xent bet di 39 Phining phip thnc hien Ngudi so' dyng Sau khi clang nhap thinh c8ng, chtrang trinh se hien thj ban di: cho ngueri dung. Ngteri dung c6 the tien hinh the than tic tren ban da nhu: - Chuyen vj tri ban di: Ngu6i dung c6 the Iceo tha tai vj tri bat kit tren bin es de di chuyen bin 8 - Thu phang: Ngtr6i dung se dung hai ng6n tay chain vio bin dO. De pheng to ban di ngubi dung can dua hai ng6n tay ra xa nhau vi nguqc loi de thu nho ban M. Ngoiti ra nguti dung cling c6 the sir dung nut +1- de thu pheng ban 8 - Xoay biut db: NguM dung c6 the xoay bin (18 bang cich xoay 2 ngan thy tren bon M. Khi da bleu tuqng la ban se duqc hien len 6 phia tren ben trait cita man hinh, giup ngutri dimg xac djnh duqc phtrcmg hue:mg. Chuang trinh of if Chtrcmg trinh c6 nhiem vu hien Si ban da cho ngutti dimg. Cac Sao tic ca ban el:a ngdri dimg tren bin dO se sir dung mac dinh dm APL Cac thao tic yea vj tri bon be se duqc de' cap 6 phan sau. Ban 8 se duqc nop S djch vu do Google cung cap. Da lieu ban dO c6 the duqc Google thay dOi ma khong bito veri ngueri sir dung. Day se la giao dien chinh cent bin dO, not hien thj cic SAM plan chinh vi la nai de thuc hien cac chirc fling khic. Server Chirc nang nay kheing yeu cau gi S phia server, toy nhien khi vio den man hinh nay client- server se din hinh ket not vii nhau trong mot tien trinh ngam, sin sang cho the hoot dung tiep theo Cie yeu au d$c biet kink Thiet bj can ph& cAft ket n6i mpg 40 %to a uy _tun auk t/0414 , a ,bosic a temlown and : NYIE 1+ Ar KNU IAIINE otlio 0 Gino din minh hqa SSW !fink 4-4: Min fig bin di 41 4.3.4. Char ming xem vj tri tha minh UC #0004 XEM Ni Till CUA MiNH DO phis kip: 1 Me ti Chat fling nay cho phep nguieri dung xem vi tri cha mirth tren ban dO. KM nguari dung di di chuyen bin dO di xa va kh6ng con nit vi tri dm minh, claim ning nay se di chuyen bin dO den vi tri hien tai cos ngueri dung. Tic nhan Chhth Nguai sir dung Pity Kitting co Tiin thin Idin Ngueri sir dung can ding nhjp vim chucmg trinh lit kifn Thinh thug Chuang frith hien thj vi tri dm ngtreli dimg Iii Chuang trinh kitting the hien thj chinh Vic vi tri ngueri dung So• a6 luAng cong vitc Sudo Wing caw*: Chic ning hien NA tido minh ""'ding ONitwAndroid Did' vl) dla Google Server Ca sada* thau ( ) Rhein& 4- liudulainthl vitisira Natitisl —I tkaalttlitit – Sole 4-6: Xent 4 tri ctia fidnk 42 : Nauoi au dung Vi tri novo' dung A9611.59thal 3:Yeuay dihviff So* do trinh ty 2: Xem ban do() ktelnIzaid SiMarki : lien el ban doff 4: Tra ve 1 ier toa do ôaeateằ S : Tao ryas') 6 Danh dau tri ten bin do() Yea cau Nen thhi tiQ ltusy dui vi In ban do° Sold 4- 7: Dinh ty Xem vJ trf minh cril 7: Chon chuc rang him ti vi tO0 9 43 Phut:mg phip thyc hien Nguiri air dyng Ngued dung chi can barn vao nut "Vi tri cith tai" hoic "My location" de thyc hien chic rang nay. Khi de ban d6 se duqc di chuyen den vi tri hien alai dm ban. Chuang trinh lir it Try& het di sir dung duce chic nang nay, chuong trinh can phai ley dtrqc vi tri hien thed ctia thiet bi. Cemg viec nay se duqc thic hien ngiun ngay khi ban de duqc hien thi. Trong Ian dau tien de tim duce vi tri, chuang frith se dinh du vi tri coa ngubi dimg tren ban di) bang bieu Ming d#c biet, Clang thed di chuyen ban d6 den den vi tri ngtrai dimg. Trong trueng hqp chua d6 tim dtrqc vi tri, bieu tuqng vi tri cim ngueri dung se chua dtrqchien len. Nitu vey, thvc chit di chic tang fay c6 thi hokt Ong dint thi an pluii c6 met chic [tang quan trung kink d6 hl chic Ming d6 tim vj tri. Tuy nhien chic nAng nay khOng yen au ngubi ding time hien thao tic nito cal, vi vey chic nAng de tim vi tri se dive m8 ti tai defy. De thiet bi c6 the lay dtrqc tqa di) vi tri hien tai cult mlnh, thiet bi an phai duqc bit GPS hoc mang di dOng 3G/Wifi. Tuang ing vai de car% c6 hai tech de ley dtrqc ma deo hien tai dm thiet bi. - Cach thi nhit la si dyng 4 tinh dm Google, hay chinh la se dung GPS. Ckh nay se cho ket quit chinh xac, tuy nhien vi you au ket n61 den ve tinh, nen theri gian de lay duqc tqa deo se lau hen, dong thed neu thiet bi dirge d#t a trong nha thi dm nhu kitting the si dung duct Viec sir dyng GPS ding ten pin han viec si dung mpg di dijng hay Wifi. - Cach the hai la si dyng mpg di dung 3G/wifi. Cach nay cho ket qua nhanh han so veri dung GPS, my nhien deo chinh xic ciut rich nay lei 'thong cao bang GPS. Chinh vi vu va nhtrqc diem cim hai phuang thirc lay vi tri nay, nen ngtred lip trinh thtrimg sir dyng ket hqp di hai cash a cho ket qua chinh xac va nhanh nhat. Sau khi ley duce vi tri cita thiet bi, chtrang trinh se Sixth dau vi tri de bang mijt bleu ttryng dic biet, d6 la vi tri ciut ngubi dung. Tir day khi ngubi dung biun vao nut "Vi tri ctia tOi", ban 416 se dtrqc di chuyen den vi tri nay. Server Chic nang nay khang yau cau gi ti server. Tuy nhien tqa du ngubi dung se duqc cip nhit len server a chic Ming tiep theo Cic yen cin d4c Met Mk De sir dung chic Ming nay ngubi dung can phai bit GPS hoic mang 3G/wifi de thiet bi tien hanh d6 tim vi tri 44 Giao difn minh hqa Rink 4-5: Dinh 4 vd kiln thi 4 tri ngwt3l ding 45 4.3.5. Cher ndng xem vj tri bon be UC #0005 XEM Ng TRi BAN BE DO phirc tgp: 1 M8 ti Chile nAng nay duqc thyc hiAn mdt each tq ddng, khong can ngueri sir dung tfic ding van chtrcmg trinh. Chuang trinh se ty ddng tai danh such ban be ciut ngubi dung ve tir phis Server vet hien thj drinh dAu tren ban dO. Ngueri dung co the ttrcmg tac veri ben be Wye tiep to nhOng vi tri da ducrc dab dAu. Tic nhAn Chinh Ngtred sir ding Pity !Chong co Tien dieu Men Ngtred sir dyng can dAng ninip de sir ding chirc nAng nay Hp dieu kitn Thinh thng Vj tri ban be duqc hien thj tren bin di Lai Vj tri ban be khong duce hien thi tren bin dO 46 Set do bang ceng viec Sc db lubng Ong vlec: Chin fling hien thi vi trl ben be 6 Ngulli thing °a Thigt bi Android h vy th Dic e Googie Server CO sit der lieu 0 ( lat dliu • IS try bin et Chl *du lip dm* 'Mitts bi TA, nhin rib yis If TO do • NIS anis Mich bin Wane, ay dap* WI bin Sal Sidi/ Iglu _ Cid St 0.• vt Own / GOI yke du ay a* Tip nhis va a If )4u chi val &Mato a Ow loampiv. --4---- My dog No Non tit as i MS dolor an win ant Td It a4 do Oiest / tinTheab:In 4 / e Tip dirt au NM Main WA 4 C most ) Sold 4-8: Xon ;Or( blue bl 47 Sa dO trinh tv KD 0 0 KJ° 0 r9~d r9 spa 3: Yeu au by pat et tank )1 4: Lay ilst S. ban 5 doh S. Ue l O dot edits :Tra ye drh nth ben tE 8 :Iv, dot nth be 9 ve at swain be so a 4-9: Trink ty Xem vj trf bps bl 48 Phiroug phip thyc MO Nguiri sir dyng Chic nAng nay killing yeu cau ngueri ding tac dOng vao chuang trinh. Chi can ma man firth cim chuang trinh len va danh sach ban be se duqc nap ve met cach tv &Ong. Danh sach bon be cling dugc c#p nh#t lien tvc, dam bao vi tri dm ban be se dugc c#p nh#t chinh xac nhat. Chung Irish xir It Day la met ding viec tv dOng thvc hien kh8ng can thao tic cia ngtroi dung. Cong viec nay you cau giri va nh#n ket qua tir server cho nen can phai d#t trong Asyntask. Cac ceing viec chuang trinh can thvc hien: - Chuang trinh giri you eau lay ye danh sach ban be dm ngutri dimg: Getfriend Chi jr la ID cia ngutri dung kh8ng duqc c8ng khai, nen chuang trinh se thvc hien chic nAng nay met cach ix dOng, ngueri ding Idging the can thiep vao chive nAng nay. - Sau khi you cau duqc giri di, chuang trinh se nhon ve met danh sach clic ban be di dugc ket ban, danh sach c6 cau trim kieu xau (String), cau trite danh sach tra ve nhu sau: Chuang trinh se tien hanh phan tich danh sich nay va danh du vi tri ban be trEn bitn dO. - Sau khi nh#n duqc danh sach ban cling vol vi tri tuang (rug, chtrcmg trinh se lay ve met vai thong tin co ban cilia ban be, gem c6 ten day dti dm ban va thin gian ding nhop glut nhat. Yeu cau dugc giri den Server vol cau tic: Getinfo - Chuang trinh se ling nghe ket qua tra ye tir Server, sau di sir dvng ket qua nay a hien thi vi tri ban be tren ban dO. - Ngueri ban dang Online se ci bieu ttrqng mau di, neu Offline se 6 bieu tugng mau xim. - Trang thai Online dm ban be se duqc chtrang trinh cep nh(it lien tyc, sau met khoang thbi gian nhat dinh chtrcmg trinh se giri yeu cau den server de lay lai th8ng tin ye danh sash cling nhu tang thai cia ban be. Thao tic nay sir citing TimerTask. Server - Sau khi nh#n dirge yeu cau lay dank sach ban be tir phis Client, Server se tian hanh truy xuat ca sir de lieu va lay ra the thong tin sau: 11D dm bon, chi ngubi di the nh#n you cau kit bon mil dirge lay ra (Status bang 1) 3 Vi tri dm ban twang irng, bao gam hai gia tri II Latitude va Longitude duqc lay ra tir bang Location - Sau khi lay ra the th8ng tin nay, Server se dua de lieu thanh dm tric nhu sau trtrac khi giri ve cho Client: 49 - Ngoai yen cau lay ve danh sr ch ban be, Client con yeti eau lay ve mOt 96 th8ng tin cim ngtreti ban tucmg (mg, khi nhon dugs yeu au nay Server se tien hanh lay ra cac thong tin sau: 3 LastUpdate: Thai gian gait nhat ma tqa dg dm ngtreri clang dtrqc cop nhat. 3 Status: Trang thii clang nhOp cim ngtaai clang Sau khi lay ra cac th8ng tin tren, Server se dtra ve clang sau truem khi tra ve ket qua cho client: Clic yeu au d$c biet kink Thiet bi can co ket nei mong Giao difn mink hoa I Them ban audio Din tz; WM 011 i it TRUNG I VINOIDEV eke n _ 12. It 21.23. 2S. MASI • le al Mink 4-6: Xem vi Di bnn bi 50 4.3.6. Cher nang clip Milt vJ trl UC #0006 CiNP NHia VI TRi Da phire top: 2 Ma ta Day la clang viec chuong trinh dux hien mat cach tkr clang, khong yeu au thao tac nao to phia nguiri dung. Chtic ang nay a ithiern vu Op nal tqa des dm nortri dung voi server. Toa da nay se duqc sir dung de hien till vi tri yeti ban be. Tic nhAn ChInh !Chang a phy !thong co Tien diiu kien Nguoi sir dong an ding nap vao chtrcmg trinh dHit kien Tashr . V1 tri ngutri dung duqc ap nat den Server Iii Vi tri ngtrai dung khong duqc ap nh#t den Server sor a bong Ong viec So ela hibng dmg vitc: auk anti cop nhit vl td otigulA dung QMit bi Android Dich Ai dm Goa& Server '~ Cast/delft at Oa Sachem; is* eel Ma A • 41•••••kti than I • 100, litIkk t ant awl,' arts tonged hellion all fitness 7/ obi I' *Avis • bi In — TM'S; a qui whib Ord P•Mbil•Ads Saw Sea 4-7: CO dr( 1 1 vj trl 51 Phircmg phip thvc hien Nguiri sir dung Day li mOt cong vies to dOng thyc hien khong an thao tic ctia ngueri dung. Chuffing trinh xir I C8ng vies nay yeu au oh vi thin ket qui tir server cho nen can phai clOt trong Asyntask. Cac cong viec chucmg trirth can thyc hien: - Sau khi lay duqc vi tri dm thiet bj, tqa do curt thiet bi se duqc Itru lai - Dua tqa dO vio ciu lenh: updateloc Trong do latitude vi longitude la hai gia tri dai dien cho tqa dO thiet bj ctia ngueri dimg. - Cid you eau tren den server - Nha'n ket qui tri ve tir server Server Server sau khi nhan duqc yeu ciu tar nguCri dung se tien birth cop nhat vio co so der lieu. Tqa do am ngtrad dung se duqc ghi vim co sec dii lieu de phyc vu cho cic chirc ning !chic. Sau do server se tra ve ket qua cho client timing bsio viec tip nhot tqa des thenh cong hay that bai. Cie yell au dee biet khic Thi6t In can c6 kat n6i mang Gino then minh Ms 52 4.3.7. Char ndng gal yeu cau kit ben UC #0007 GUY YEU CAU KET BAN DO phut top: 1 MO ta Chuc cling nay cho ph6p ngueri dung gUi yeu cau them ban m6i. Ngu&i ban nay se nhin duct yell eau ket ban, neu viec ket ban dirge xac nhon thi ngued ban nay se duqc them vao dank sach ban be cim ngu&i dung, clang then vj tri etia ban be cling se duct hien thi len ban do. Day la met trong nhOng- chat ring chinh cua chuang trinh 2!Friend. Nguei dung co the chia se vj tri veri ban be, dang then biet duqc vj tri ban be cua minh. Nha in, du 6 bit cu nai dau, chi can ban be sir dung chucmg trinh nay, ban cling c6 the a clang tu hop va gay bat nger cho ngtreri ban ctia minh. Day chinh la chat Wing dem ban be den gin nhau han. Khi ngueri dimg nhip ten ban, chuang trinh se tien hanh truy xuat den server di !Ay cac gia tri gqi , ket ban, &up nguai clang them ban met tech thuin tien han. Tic nhin ankh Ngutri sir clung Thy Khong 05 Tian di$u kiln Ngubi sir dung can ding nhop vao chuang trinh Hu di u Idfn Minh Sing Yeti ciu ket ban duqc giri di Iii Yeu ciu kit ban Miring duct giri di 53 s. a keng ding viIc Saab 'Ong Ong vi.c: Chat Mug seri lieu au kit ben Sgutti dims a Thigt DI Android Al Dich cua Goggle Server 3Casfrdirliou Bit au ( NI4p tin bin va bigrn ntit Itara W Ian dain diS Tin* va wit II yiu du thIm bon ( Mr/P In Mau at W bin W t auk* o MIL hit Ina / ----4-- /WA 1/ ,swarm phianst Ca loft oil a cho deft 4 ..1] Win 61 thane* do TA erg Pad* Sc &i 4-10: Girt yin cdu kit ben 54 Phtrong phip thyc hitt' Ngueri sir chum Tren giao dien chink dm chuang trinh, nored dung se nh#p "ten clang nh3p" cim tai khoin ban be mien them, sau 46 bam nut "Them" hoc "Add". Khi ngtreti dung nh#p ten ban, chuang trinh se hien till gqi 9 ket bon, ngtred dung c6 the chop ngay S danh sach gqi 9 new Being nher ten tai khoin dm ban minh. Chuang trinh se phin he' cho ngtrai dimg viec them ban la thinh cling hay that bai. Neu them ban thanh cling, ngueri ban Wang (mg se nhO'n duce yeu au ket ban. Tsang hap ten ban vira nhjp &I c6 trong danh sach hoc da gUi yeu cau, chuang trinh se fien hanh bao 161 vi Idling girl them yeti eau ket ban. Clurcrag trinh Kir It Sau khi ngueri dimg bam nut "Add" hoc "Them bon", chuang trinh se thyt hien xi: 19 !Meng cling viec sau: - Lay ra ten ban ma ngueri dung mien them - Dua vio eau lenh: Addfriend - Gfri cau lenh tren den server. Thao tic nay se duqc d#t trong Asyntask - Nhem ket qui fir phia server vi thing ha° cho ngueri ditng. - Neu them ban thinh cling, yeu cau ket ban se duce girl den ngueri ban Wang (mg. Server Sau khi nhOn duqc yeu au them ban S phia client, server se tien hanh cac cling viec sau: - Lay ra gii try' tin ngubi dimg, ten ban can them - Tien hanh kiem tra xem ten ban c6 ten tai tong ca ser de lieu hay Wong - Neu ten ban thing ten tai, server se tra ve kit qui cho ngtreri dung - Neu ten ban ton tai, server se tien birth them ban ghi mei vao ca so du lieu Tiling thai bang 0 clang nghia veil viec yeu dm ket ban nay chtra duqc xic nho'n. Khi ngueri ban Wang Ung clang nh#p vitt chuang trinh se nhjn duce yeu cau ket ban nay, khi 46 hq c6 the xac nh#n hay tir chei yeti cau kat ban 46. - Sau khi them ban ghi thinh tong, server se tra ve ket quit thong bao vat ngtroi dung viec girl yeu cau them bon di theft ding. CM yiu au qe biet khIc Till& 1,1 can phai ci kit nal mang 55 Ocavloua webs *en !) Giao digs minh boa HIS 4-7: Gni gu au kit bon Rink 4-8: Meng Might thim yin au 56 4.3.8. Char nag xdc night yiu au kit ben UC #0008 )(tic NHAN YEU CAU 'CET BAN Di) phut tap: 1 Mo tai Chirc nang nay cho phep ngueri dung zac nhon yeti au ket bon to met nguen clung !chic. Chirc nang nay giim ngueri clang dr the kiem soat duqc viec chia se vi tri den met ngueri ma minh khong mong muton, beri vi viec chia se vi tri that ra la met van de rieng to va can c6 de tin c#y cao. KW nh#n dirge met yeu au ket bon, ngueri clang c6 the lua chun deng 9 hoec to ch6i. Neu yeu au duqc deng 9 (xitc rile thi ngueri bon do se dtrqc them vim danh sash Nut be. Tic nhan Chinh Ngtrei sir dung Phy Khong ce Tien diau Icifn Ngtred sir dung can clang nhop vacs chuong trinh H u di u kifn Thhnh ding Trong thai ciia you au ket bon dtrqc cep nh#t Lie Trong thai cita yeu clu ket bon khong dtrqc cop nhOt 57 So d6 hding cdng viec Sc ct lubng cans vier Chat ring xac nhan yiu au ket ban Ngvad dung Mitt bi Android Dich vu dm Google Server Ca sir dai lieu C Bka ) sin 111 bin /lb Girl viu du Wayyto do ka blia Na then vi 4irlf *Su • Illk dards sr y1u doa Liy dank sichykt clu Sibs% &costs 0 41 &Hu • Gia1kItcpsite Dinh 141 an 4 Om du Tr thil bk 11•1 0111 1•J131 11 Inn flip nblo ve24)0 Wu clo i Gal thong tin I/1c Sado Sow e • • Girl* trans thil lilt bin UPS. (1) land taw kit *dr -) XS ifhp dm IS bin --V *NM / dna& Se di 4-11: X& nh(in yin can kit bpn 58 Phtning phip thyc hien Ngirtri sir dyng Khi c6 met yeu dm ket ban, chuang trinh se hien thi th8ng tin chi tiet coa ngueri ban mutin ket bp, ngueri dung sau khi xem th8ng tin nay co the In chien ding 9 hoec fir chin yeu ciu ket ban di. Neu ngueri dung chp fir chi:Si, yeu eau ket bp di se duqc tool b6 va thong hien thi 10 khi ngueri dung ding nhep lei. Neu ngueri dung ding 9, danh sich ban be se duqc cep !diet loi va vi tri cua ban tucmg ling se duce hien thi tren bin di. Chuang trinh xii If Chit ning nay se dtrqc chtrang trinh bit du lir ding. Sau khi ngtreri dung clang nhop, chuong trinh se yeu eau server tra ye danh sach the yeu eau ket bp dui ngtreri sir ding: Getrequest Sau khi nhen duqc danh sich the yeu ciu ket ban hi server, Wang img iced null yeu ciu chuong trinh se hien met man hinh hien thi thong tin chi tiet cis ngueri bp tucmg ring, bao pm: - Ten tai khoin - Ten day di - Si dien thogi Ngtreri dimg sau khi xem th8ng tin nay se hra chqn thing 9 hose fir eh& you eau ket ben. Trong truing hqp ngtrii dung ding 9, chuong trinh se girl thong bio den server a xic Mon viec them bon: Accepffriend Sau di, trong lin nap loi danh sich ban be, vi tri bp be vita du% them se hien thi tren ban 6. Trong truing hqp ngueri dung ti chii yeu eau ket bp, chuong trinh se girl thong bio tit choi den server. Viec nay cling tucmg ring yen viec xia met bon be khoi danh sich. Sau khi ngtrii dung Itra chqn xic nhen hoec ding 9, man hinh xic nhen yeu ciu se ding 10 vi tri ve giao alien bin 46 dm chuong trinh. Server Sau khi nhen duqc yeu ciu hi ve danh rich yeu au ket bp caa met ngueri dung, server se tiers hanh truy xuAt ca ser de' lieu vi tri ve ket qui cho Client. Trong truing hqp khong co yeu eau ket bp nio, server se tri ve ket qui li "empty". Neu ngueri climg ding 9 yeu ciu ket bp, server se tien birth cep Met car serdi lieu. Neu ngueri &mg tir chii yeu ciu ket ban, server se tiers hanh xia bin ghi khii ca ser der lieu. Viec nay cling pin giOng nhu 114 ket ban. Csie yin an *bift Ithic Thitt IA can co ket mai mpg 59 Mut nquot moon kit TM khoin: test6 Ten: Phnm Tula T then Movie: 0947493260 Giao Bien minh hos HMIs 4-9: Mk nhan ylu du kit bon 60 4.3.9. Cher nong tim during vi trl km UC #0009 TIM DU ONG DEN VI TRi BAN DO phis typ: 3 Me ti Chirc nang nay cho phep ngueri dimg c6 the tim dugc &rang di den vi tri ban be cim minh. Diremg di se dirge dinh diu tren ban db, yen diem bit diu la vi tri dm ngtrai dimg ve diem cuOi la vi tri ban mkt ngu&i dimg. Ngueri dung chi can lam nhOng thao tac rat nho la c6 the tim dugc duerng di din vi tri ban be. Tic nhin Chlnh Ngtrai sir citing Thy Google Service Tien die', kijn Npreri sir dung can clang nhitp vio chuang trinh, Google Service phai hog ding HOn (lieu Thinh cOng Chuang trinh hien thj duemg di den vi tri ban Luang Ong kiln iii Chuang trinh kh8ng hien thi throng di den vi tri ban Luang Ong Sa a luting cang viec So db Iubng am viec: thine ning dm dubng dfn vi of ban oNgo&I thing ti 'Ma bi Android Did vy co Go of& a a Co sit dr/ libu C °itdiu ) • Own bon bib main tor th••trag Sib tit bin dti t Gin Au du din Tiling* vi a I# AW Aga. Min MY qa Mt Gorda Siva • CS shit bin db Se di 4-10: l'im &rang di din vi Inc bon 61 Phtrang phip thisc hien Ngatri sir dyng Tren ban da, ngueri dung chi an bam vao met vj tri ban be bat ki di duqc hien thi va dqi trong giay lat. Chuang trinh se tien hanh zit 15 , va tim throng di den vi tri ngueri ban tuang img. Trong met dt6i diem chi c6 met dui:Mg di duqc hien thi. Neu nguiri dung him vao met ngueri ban khk, dtremg di cu se duqc x6a di va dutmg di den vj tri ban mai se duqc hien fill. Chuang trinh xi ly Chirc ning nay sir dung Direction API ctia Google de thtrc hien tim dyeing di giffa hai diem. Diem bit diu la vj tri ctia niorai dung, diem ket th6c la vi tri cirri ban be. Khi ngueri dung btun vao met marker dpi dien cho met ngueri ban, chuang trinh se tien halt thu thop tqa do ciut ngtroi dung vi dm ngueri ban vira dtrqc brim vao, sau de girl yeu eau den Direction API ciut Google. Yeu cau nay can c6 ket not mpg va ch do tie, chinh vi the can phii dat trong Asyntask de Minh lam treo ding nhu ForceClose img dong. Sau IN nhk duqc ket qua tra ve, chucmg trinh se tien luinh hien till duimg di ten ban d6. Khi ngueri clang bam vao met marker dal dien cho met ngueri ban khk, dtremg di cii se duqc x6a di va clueing di mai se duqc hien len. Cach sir dung Direction API se duqc de cap 6 phin 4.3.1 Server Cate yea au dee biet khie Thiet bj can co ket not mpg Gino diem minh him Them bon a Svi„ I" ThIPTY Sr urow Irettsta+10i • .,. Y torr3 I , Ilacts t 4.4a OM TIrehltsittNis Ore " ISO , I . SIN Binh 4-10: 79nn &Meg dl din vj trf hut 62 4.3.10. Chose ming xem thong tin km UC #00010 XEM THONG TIN BO Ê14 phfre tap: 2 M8 to Chirc ning nay cho phop nguai dung c6 the xem th8ng tin chi tiet ve met ngtreti ban trong danh sach ban be cim minh. Khi man hinh chi tiet ban be hien len, ngueri dung c8 the thyc hien nheng chirc nang khic nhu giao tiep ved ban be bing tin nhin, dien thotti hoc hay ket ban. The nhin ChInh Ngueri sir dyng Phy Google Service Tan Su kio Nguen sir dung can ding nhep vio chucmg trinh Hiu dieu Thinh thug Thong tin ban duce hien thi ki'n Lgi Thong tin ban khang duce hien thi Srr d6 tang cong vi%c So S luting tong Sr: ChCrc MN{ gem thong tin bon Nguti citing rd el Android fl mid ilich vy as Goggle Server 3 Co 0 dtt lido Wđ" MP ohist vh re ( ) It Wm es Mon bps bit mas own KS Ai bin a Ar AZT G,4 Ow the Ify See is 116 nit ye ..)0# Nu du —4 0 mar ts I guru Seig an Of tenor vb Geode UMW Lie Mao IM tir co vino Nu • Is bb Nan IN la ma dos meanie CA Mara. MS 11, ( la *Sr ) Sc di 4-11: Xem thing de bgn 63 Phircrng phip time hiĐn Ngtrei sir dyng De sir dung chic nang nay, nguii dung chi can thvc hien nhing thao tic don gian sau day: - Barn chqn ban be di duqc danh dau tren ban da - MOt cira so thing tin Infowindow tucmg (mg se duqc hien len - Bilm chqn vao cira so InfoWindow di, man hinh chi tiet ban be se duqc hi'en len. - Khi muffin quay Iai ban di, nguai citing chi can barn nut "Back" cim thiet bi Chuang trinh xir It Chirc nAng nay yeu au ngueri lap trinh phai ling nghe vi xir ly sv kien barn vao InfoWindow cita marker. Khi Info Window duqc barn vao, chuang trinh se tien hanh thu thip thing tin cim marker di va truyen den man hinh hien thi chi tiet. Thong tin chi tiet dm ban be se duqc tai ve tic Server, rieng thong tin ye dia chi caa ban se duqc lay ye ter dich vv dm Google. Server Server ci nhiem vv ling nghe yeu cau tir phis Client. Sau khi nhan duqc yeu au lay thing tin, Server se tien hinh truy xat co sir de lieu va tra ve ket qua tucmg Cmg cho phia Client. Cie yeu au d$c hip khic Thiet bi can co ket not mpg 64 dhthanglong Dai hoc Thing Long 137 Nguyen Xign Dai Ki Mai Ha NOi 201311-14 Giao din Sub boa Binh 4-11: Xem thong tin bpn 65 4.3.11. Chic tang giao vai ban UC #00011 CIAO TIEP VOI BAN DO pink top: 1 Me ti Chirc rang nay cho phi!, ngubi dung c6 the giao tiep, len loc vii bon be. Day chinh la diem mph dm cac thiet bj di dung. Chuc rang nay lig try ngubi dung nhin tin, pi dien cho ban be mOt cach nhanh ch6ng ma khong an ma danh bo hay (mg dung than tin, chi can ban be a trong danh sach IA vii nhang thao tic rat nhanh gm la di the lien lac yin ban be. ne nhan Chinh Ngtroi sir dung Mg 'Wong co Tan diiu kiln Ngutri sir dung can ding nhip vac) chuang trinh di nl ang kifn Iii !Chang the giao tiep vii ban Wong ang So' do iubng cong vies ... Thay cho viec truyen tin hieu true tiep yin v4 tinh, A-GPS ket not tin hiOu qua mot "tram trung chuyen" la mot he thOng may chit hit try. He thong trung gian nay xac djnh vj tri cim thiet bj so vii cac turn thu phit song elm cac mpg Bien tho3i trong gian trong thu vve va tit d6 tinh town ra vi tri tren he thOng GPS. MOt duet bi tich hqp ding nghe A-GPS Bien hinh can cit cac ket not de lieu (qua mpg GPRS, 3G hoOc Wi-fi) de c6 the truyen tai de lieu qua lui vii may chit trung 86 gian. Nhieu thiet bi hi) trq A-GPS van cet the hoat Ong ved ding nghe GPS chuan khong qua ha trq cua mang truyen dAn, tuy nhien trong met so twang hqp, viec xac dinh vi tri theo theri gian thuc se gap nhieu kh6 than do thong tin tir ve tinh den thiet bi khong On dinh. MOt trong nhang tram trong chuyen la can tram BTS. De hoat dOng, lien thoai phai ket n6i yeti tram chuyen tiep cua nhit mpg gqi la BTS, ma vi tri cua BTS la di dinh nen ve ca ban chi c6 the biet thue bao de dang 6 khu vuc nao chit ko the chinh xac den vai met nhu GPS duqc. Tuy nhien, tai met than diem thiet bi di dong ca the nam trong yang phit sang cua nhieu tram BTS lchic nhau. Dua vao cluing dt) song, t6c dO giri va nhan tin hieu c6 the xac dinh met cach tucmg dOi khoang cach tir thiet bi den tram BTS, tit da cep the xac dinh duqc vi tri cua thiet bi. c. Wifi Ban chat cua viec dinh vi bang Wifi chinh la viec xac dinh vi tri cua Router. Pham vi phat sang cua met Router la khong Ion, nit& la din van Router cua ho gia dinh thi pharn vi chi khoing vai met. Chinh vi the neu thiet IA di dOng dang sir dung mang Wifi nao da thi vi tri cua Router kha gen yeti vi tri cua thiet bi. De c6 the xac (filth duqc vi tri cua Router, Google da den hanh thu thap thong tin tit rat nhieu thiet N chay Android. Klu bat (Lich vu chia se vi tri cua Google, man dung da clang y cho phip Google thu thap cat thong tin tit thiet bi Android, trong d6 c6 ca thong tin ve mang Wifi ma thiet N dang truy cap. Tai met than diem ce the c6 nhieu thiet bi cimg ket n6i van met Router Wifi, sau !chi thu thap duqc mot b0 du lieu lem nhu vay, Google se tien hanh khai pha du lieu — Data Mining de' lay duqc cat thong tin can thiet. Tit cat thong tin de, Google a xay dung duqc ca sec dtt lieu va vi tri cua cat Router va sir dung de dinh vi thiet bi di dOng. 87 4.4.3. VeIn iti an suit cep nhet di? Day win la throng trinh host Ong theo mo hinh Client-Server. Vi the viec trao d6i du lieu giOa may chit va may khach din ra lien tuc va kha thuOng xuyen. Nhung nen nher day la chuong trinh chay tren thief bj di Ong von tai nguyen c6 han, vey viec trao d6i nhung gi von server ding can phai firth den: - Khi ngtreti dung sir dung chuong trinh: Day la luc chucmg With hoat Ong yeti hieu suet cao nhAt. Viec cap nhAt danh sich ban be, day vi tri ngubi dimg len server duqc thqc hien yeti dO tre ngen - Khi nguesi &mg sir dung chirc nang khac cfra chuong trinh hoec dE chucmg trinh chay ngem: Luc nay viec cep nhat danh sach ban be la khong can thiet. Din thai viec day vi tri len server cling se duqc tien hanh chem ham nhim tiet kiem chi phi. 88 g id : int(11) # user_id : int(11) # lati : double # longi : double m lastupdate : date id : int(11) m login : varchar(30) m pass : varchar(32) m name : varchar(30) đ phone : varchar(15) # status : int(11) 2 id : int(11) * user id : int(11) m date : date id : int(11) # user_id - int(11) # status : int(11) 4.5. Thief ke co ser dit lieu 4.5.1. Mb hinh quan he So di 4-17: MO hank dlt lieu quan he 4.5.2. Clic bkpg dir lieu 4.5.2.1. Bang users a. Cau true bang de. lieu ID INT(11) Khong Auto Increment Khong LOGIN Varchar(30) Khong Khong Khong PASS Varchar(32) !Chang KNIT* Khong NAME Varchar(30) 'thong Khong !thong PHONE Varchar(1 5) Co Khong [Chong STATUS Int(1 1) !Chong Khong [Chong Bang 4-2: Bang Users b. t nghia ciut cfic gia trj - ID: Gia trj khda chink dinh dank, gia tri nay dugs sink tu dang. - Login: Ten tai kholin cfla ngubi clung, sir dung cimg vOi mat khau de ding nhap vao chuong Dinh. - Pass: Viet tit ciut Password, la mat khau dung de dAng nhap. - Name: Ten day dfi elm ngubi dimg, ngubi dimg c6 the nhap vio tity 89 - Phone: So then thogi cim nguei dimg. Gia tri nay do ngued dung nhAp vao, dung de thuc hien chic ning gei dien va nhin tin. - Status: Gia tri nay the hien tang thai ding !IWO cua nguei dimg. 4.5.2.2. Bang Location a. CAu Mk bang MY lieu `pity 4 ID INT(11) Khong Auto Increment Khong USERID INT(11) Khong !Chong USER(ID) LATI DOUBLE Khong Killing Khong LONGI DOUBLE Khong Khong Khong LASTUPDATE Date Khong 'thong Khong Bang 4-3: Bong Location b. t nghia cim cac gia tri ID: Gia tri khea chink dinh dank, gia tri nay duce sink tv deng. UserID: Gia tri nay la kh6a ngoai lay ter bang User, dung de xac dinh met user tai ban ghi hien Mi. Lati: Viet tit am Latitude, la gia tri Kinh de, ding vei gia tri Longi de xac dinh vi tri cua ngubi dung. Longi: Viet tit coa Longitude, la gia tri Vi de, ding yeti gia tri Lati de xac dinh vi tri nguei ding. 4.5.2.3. Bang Friend] a. CAu true bang da lieu Bang 4-4: Bang Friend] 90 b. nglifa cua cac gia tri - ID: Gia tri kh6a chinh dinh danh, gia tri nay duqc sinh ttr dOng. - USER ID: Day la kh6a ngoai lay tit bang Users, day la ID dinh danh cita ngu&i da girl yeu cku ket ban. - DATE: Ngay ma yeu cau ket ban duce gni di. 4.5.2.4. Bang Friend2 c. CAu frac bang da lieu ID INT(l 1) Khong Auto Increment Khong USER ID INT(11) Khong Khong USERS(ID) STATUS INT(11) Khong Khong Khong Bring 4-5: Bing Frlen d. nghia cua cfic gia tri - ID: Gia tri Schee chinh dinh danh, gia tri nay duqc sinh to Ong. - USER ID: Day la kh6a ngoai lay to bang Users, day la ID dinh danh cua ngued duqc yeu eau ket bp. - STATUS: Trpg thai cua yeu au ket ban. Neu trang thai nay bang 0 thi yeu eau ket ban nay chua duqc xic nhan, neu bang 1 thi yeu cAu di clime xfic nhan, 2 nguen tuang *rig &I la bp cua nhau. 91 4.6. wet kiln va djnh hating phat trien 4.6.1. Kit qua dqt duvc Sau met thai gian tim hieu va dqc tai lieu, em da lap trinh thanh cong de tai coa minh vai san pham la chucmg trinh 2Friend — chucmg trinh cho phep ngutri dimg co the chia se vi tri cita minh veri ban be, nguai than. Chuang trinh da co Wang din day de chirc nang, nhung day la chucmg trinh huang teri rat nhieu ngutri sir dung a khip nai tren the gieri chir Miring Hang a Viet Nam, nen viec chua lam hai long nguai sir dung la !thong the tranh kh6i. Sau khi chucmg trinh duqc trien khai, em se ling nghe icien phan hOi tir nguai sir dung va cap nhat img dung thutmg xuyen nham lam hai king nguai sir dung. 4.6.2. Dinh Inning phdt trim 4.6.2.1. Dim zing dyng ten CH Play MOt Ong dung Android muen den duqc yeti nguai ding nhanh nhat thi can phai dua len CH Play. Day duqc coi nhu la "chq Qau mei" de ngutri dimg mua hoac tai umg dung Android. Ngoai viec dau to de dua img dung len CH Play, trong th&i gian Mu ding can phai clang cao yeti ban be de tao met cong dOng ngutri sir dung, bai vi met *rig dung c6 so KKR tai va danh gia cao se thu hut ngtrisi sir dung hon. 4.6.2.2. Thu 10 nhudn tie zing dung C6 ba each thu lqi nhuan tir met img dung hen CH Play. a. Ban Ung dung Hay n6i each Ichac, ngutri dung se phai tra tien de tai CEng dung xuOng, hay con gqi la mua img dung. Cach nay thutmg duqc sir dung veri nhttng chuong trinh that sun tot, vai nheng nha san sat co uy tin. Tuy nhien day kh8ng phai la each tern uu nhat, img dung can tra phi de tai luen c6 so luqt tai it han. Han Oa, dOi yea thi Huang Viet Nam, ngutri dimg rat it, c6 the nOi la gin nhu kitting bao gia mua img dung tra phi tren CH Play. Ly do bai vi viec su dung the thanh thin wok to a Viet Nam chua phi) bien, va cling bai vi th6i quen ngutri Viet Nam van thich &mg dt• mien phi han, ding bai vi thu nhap cua Viet Nam chua cao so v6i the gieri. Chinh vi vay em se kitting chqn catch nay de Qua img dung len. b. Thu tien trong time ckmg Cfich tins' hai de thu lqi Taman tir img dung Android d6 la thu tien ben trong zing dung. Dien hinh nhu met so tr6 chai not tieng nhu Candy Crush, Class of clan... Vat pham ben trong img dung hay met so tinh nAng an phai tra phi de kich hog Cach nay cling thu ve met se den khOng to neu ting dung de hay va c6 nhieu ngutri sir dung. Tuy nhien, em cling se thong chqn each nay, ix% vi img dung ciut em khi mai dua len se 92 khong c6 nhieu ngtroi sir thing. Han nua viec tra phi it hay nhieu cling se lam ngutri dung can nhic khi sir dung img dung. Mvc tieu ban du mia em la Wong tea co cang nhieu ngueri sir dung cang tot. c. Hit quang cao trong img dung Cach cuOi cling de kiem tien trong img dicing d6 chinh la dit quang cao trong img dung. Cach nay khong yeu cau ngutri dimg phiti chi frit bet ki met khoan phi nao de sir dung chuong trinh. Lqi nhuan se dugc thu tir cong ty quang cao. Tuy nirien doi khi quang cao cling gay kh6 chju cho ngutri (king, chinh vi Vey, viec chon hinh thirc dot quang cao, vi tri dit quang cao cling quan tong de khong lam mat khach hang cita chinh minh. Day se la cach em Iva chon de trien khai img dung. 93 CllUONG 5. PHV LVC - CODE MOT SO CHIC NANG ClliNII 5.1.1. Chtit nun dung kft tdi khotin public class registertask extends AsyncTask String RegisterResult = null; protected String dolnBackground(String... awls) Bundle mbundle = new Bundled; mbundle=geantenta.getBundleExtrarRegisterBundle); ipserver=mbundle.getString("ipserver"); iffl(username.isEmply0I1pass.isEmptY011hame.isEmplyallphone.isEmplAD Socket el-null; try ( cl=new Socket(ipserver,8881); PrintWriter outp = null; BufferedReader inp=null; if(cl!=null) outp = new PrintWriter(cl.getOutputStreamatrue); inp = new BufferedReader(new InputStreamReader(cLgetInputStream0)1; Stringfl fidlname=name.splitr '2; name=""; for(int i=0;i<fullname.lengtki++) name+=(fdlnamefil); ifa==fullname.length-1) break else name+=" "; 1 outp.println("register "+username+" "+encryptMDS(pass)+" "+name+" "+phone); RegisterResult=inp.readline0; outp.println("quit"); //inp=null; outp-null; dclose0: ) catch (UnknownHostException e) // TODO Auto-generated catch block e.printStackTraceQ; ) catch (I0Exception e) I // TODO Auto-generated catch block e.printStackTraceO; return null; protected void onProgressUpdate(String... progress) ( protected void onPostExecute(String result) if(RegisterResult.equalsIgnoreCaseruser")) 94 ToastmakeText(getApplicationContextO, getResourcesagetString(R.string.please_use_another name), Toast. LENGTH LONG).show(); else iffRegisterResult.equalsIgnoreCase(false")) ToastmakeText(getApplicationContextO, getResourcesQ.getString(R.string.cannot_register), Toast.LENGTH LONG).show0; else Intent login = new Intent(RegisterlayoutActivity.this,LoginLayoutActivity.class); startActivity(login); finish 0; I 5.1.2. Char ming Ong nh# private class LoginTask extends AsyncTask ( protected String dolnBackground(String... urls) { user=tb username.getTextO.toStringO; pass=tb_pass.getTextO.toString0; login_status=login(user,pass); return null; protected void onProgressUpdate(String... progress) ( protected void onPostExecuteatring result) ( ifflogin status) Bundle mbundle = new BundleO; mbundle.putString("user", user); mbundk.putString("ipserver", ipserver); Intent mintent=new Intent(LoginLayoutActivity.this,MainActivity.class); mintent.putExtra("MyBundle", mbundle); //finish0; startActivity(mintent); finish 0; //System.exit(I); else ToastmakeText(getApplicationContextO, getResources0.getString(R.string.cannot _login), Toast.LENGTH LONG).shaw0; bt_login.setEnabled(true); 95 5.1.3. Quit niing hien tri tri ben private class updatefriendtask extends Asyncrask protected String dolnBackground(String... urls) { if(cl!=null) if(username==null) username=mbundle.getStringruser); iffid==null) id=getid(username); friendlist=gerend(id); String() friends=kiendlist.splitr "); templatIng=new LatLng[(friends.length/3)]; friendinfo=new Stringl(friends.length/3)1; kiendmarker=new Markerlikiends.length/311; for(int i=0;i<((friends.length)/3);i++) int currentfeint = i*3; templatIng[i] =new LatLng(Double.parseDouble(friends[current point+11), Double.parseDouble(friends[current_point+ 21)); outp.printlnrgetinfo "-Ffriends[current_point]); try fi-iendinfofifrinp.readLine0.toString0.trim0; I catch (10Exception e) ( // TODO Auto-generated catch block return " "; protected void onPostF-xecute(String result) String() friends=kiendlist.splitr "); for(int i=0;i<Wriends.length)/3);i++) String tempinfor =friendinfolij.split(" '); fi-iendmarker[i] =mMap.addMarker(new MarkerOptionsO .position(templatinglifi .title(tempinfo[0]) .icon(BitmapDescriptorFactory tkomResource(R.drmvable.ic_ofiline_big)) .snippet(kiendinfo[in .anchor(0.5f 0.5j)); if(tempinfo[2].equalsIgnoreCaser I")) friendmarker[i).setkon(BitmapDescriptorFactory .fromResource(R.drmvable.ic_online_red)); //--Get Friend— public String geOlend(String id) 96 String temp="0"; outp.println("ge&iend "+id); try temp=inp.readLineatrim0; j catch (10Exception e) ( /1 TODO Auto-generated catch block //e.printStackTraceO; return temp; 5.1.4. Chfir ming pH you cliu kit bgn private class AddfriendTask extends AsyncTask ( String status=null; protected String dolnBackground(String... urls) I Stringfriend2=tb_addfriend.getText0.toString0; if(cl!=null) by outp.printlnraddfriend "+username+" "+friend2); status=inp.readLine0.trim0; catch 00Exception e) I // TODO Auto-generated catch block //e.printStackTrace0; return status; protected void onProgressUpdate(String... progress) j protected void onPostExecute(String result) I if(result.equalsIgnoreCase(' riendname")) ToastmakeTem(getApplicationContert(), getResources0.getString(R.stringfriend noffound), Toast.LENGTH LONG).show(); else if(result.equalsIgnoreCaserexits")) ToastmakeTert(getApplicationContextO, getResources0.getString(tstring.catmot send more), Toast.LENGTH LONG).show0; else if(result.equalsIgnoreCaserfake")) Toast.makeText(getApplicationContexta getResources0.getString(R.string.catmot_ad4.friend) , Toast.LENGTH LONG).show0; else if(stang.equalsIgnoreCaserdone")) 97 Toast.makeText(getApplicationContextO, getResourcesagetString(Rstring.request sent), Toast. LENGTH LONG).show0; ) 5.1.5. Char ming nic nhpn yiu cdu kit bgn 5.1.5.1. L6y danh sach yea cdu //-------------friend request----------- private class friendrequesttask extends Asyncrask Swing request="; protected Swing dolnBackground(String... urls) if(cl! =null) if(iaername==null) usenaame=mbundle.getString("user"); if(id==null) id=getid(username); request=getrequest(id); // return request; protected void onPostExecute(String request) ( ifilrequestequalsIgnoreCoserempty")) String() requestlist=requestsplitr "); for(int i=0;i<requestlist.length;i++) Intent FriendConfirm = new Intent(MainActivity.this,FriendRequestAciivity.class); Bundle tempBundle = new Bundle(); tempBundk.putStringrfriendid", requestlistpl); tempBundle.putStringrusername", username); tempBundle.putStringripserver", ipserver); FriendConfinn.putExtra("DataButzdle", tempBundle); startActivity(FriendConfirm); public Swing getrequest(String id) String temp="; outp.printIn("getrequest "+id); try ( temp—inp.readLineatrim0: I catch (10Fxception ( // TOW Auto-generated catch block //e.printStackTraceQ; 98 return temp; ) 5.1.5.2. Dang y kit bon private class AcceptFriendTask extends AsyncTask ( String result=null; protected String dolnBackground(String... urls) try ( if(cl!=null) outp.println("accep&iend "+username+" "+Login); result=inp.readLine0; outp.println("quit"); outp.closeO; inp.close0; cLcloseO; if catch (UniazownHostException ( // TOW Auto-generated catch block //e.printStackTrace0; ) catch (lOException e) ( // TODO Auto-generated catch block //e.printStackTrace0; return result; protected void onPostExecute(String r) ( ToastmakeText(getApplicationContext0, r, Toast.LENGTH LONG).show0; finishQ; 5.1.5.3. Tic chai kit bon private class DeclineFriendTask extends AsyncTask ( String result=null; protected String dolnBackground(String... urls) trY( ifrcl! =null) outp.printlnrremovefriend "+username+" "+Login); result=inp.readLine0; outp.println("quit"); outp.close0; inp.close0; cl.close0; ) catch (UnkrunvnHostException e) ( // TOW Auto-generated catch block //e.printStackTrace(); I catch (lOException e) ( // TOW Auto-generated catch block //e.printStackTraceQ; return result; 99 1 protected void onPostErecute(String r) ToastmakeText(getApplicationContextO, r, Toast.LENGTH LONG).show(); finish 0; 5.1.6. Char ndng Qjnh 4 vj Class My Location Listener ''/ public class MyLocationListener implements LocationListener I @Override public void onLocationChanged(Location loc) Mylafing=new Laang(loc.getLatitudeO, loc.getLongitudeQ); mcurrentloc = new MarkerOptionsO .position(Mylatlng) .titk(getResources0.getString(R.string.this_is_your_location)) .snippet("MyLocation") .anchor(0.5f 0.5fi .icon(BitmapDescriptorFactoryfromResource(R.drcvable.ic_mylocation)); TempMarker.remove0; TempMarker=mMap.addMarker(mcurrentloc); if(start) mMap.animateCamera(CameraUpdateFactorynewlatLngZoom(Mylatlng, 15)); TempMarker.showInfoWindow0; start=false; (et/Override public void onProviderDisabled(String provider) I ToastmakeText( geapplicationContextO, getResources0.getString(Rstring.gps_disabled) , Toast. LENGTH SHORT).show(); 1 @Override public void onProviderEnabkd(String provider) I ToastmakeText( getApplicationContexta getResourcesQ.getString(R.string.gos_enabled),Toast.LENGTH SHORD.show0; 1 @Override public void onStatusChanged(String provider, int status, Bundle extras) II )/* End of Class MyLocationListener 100 5.1.7. Mir tang tim Strang din vi trt bgn // private String getDirectionsUrl(LatLng origin,LatLng des!( // Origin of route String str origin = "origin="+origin.latitude+","+origin.longitude; //Destination of route String str dest = "destination="+destlatitude+7+destiongitude; // Sensor enabled String sensor = "sensor false"; // Building the parameters to the web service String parameters = str_origin+"&"+str dest+"&"+sensor+"&mode=walking"; // Output format String output = "json"; String url = "https://maps.googleapis.com/maps/api/directions/ "+output+"?"+parameters; return url; private String downloadUrl(String strUrl) throws 10Exception( String data = ""; InputStream iStream = null; HttpURLConnection urlConnection = null; ay( URL url = new URL(strUrl); urlConnection = (HttpURLConnection) url.openConnectionO; // Connecting to url urlConnection.connectQ; // Reading data from url iStream = ur1Connection.getInputStream0; BufferedReader br = new BufferedReader(new InputStreamReader(iStream)); StringBuffer sb = new StringBufferO; String line = ""; while( ( line = br.readLineQ) != null)( sb.append(line); data = sb.toString0; br.closeO; Icatch(F-xception e)( Log.d("Exception while downloading url", e.toString0); iStream.closeO; 101 urIConnection.disconnect(); return data; // Fetches data from url passed private class DownloadTask extends AsyncTaslc ( // Downloading data in non-ui thread @Override protected String dolnBackground(String... url) ( // For storing data from web service String data = ""; try! // Fetching the data from web service data = downloadUrkur101); Icatch(Exception e)( Log.d("Background Task",e.toString()); return data; // Executes in UI thread, after the execution of dolnBackgroundO @Override protected void onPostExecute(String result) super.onPostExecute(result); ParserTask parserTask = new ParserTask0; // Invokes the thread for parsing the EON data parserTask.execute(result); private class ParserTask extends AsyncTask<String, Integer, List>>> I @Override protected List>> dolnBackground(String... jsonData) ( JSONObject jObject; List>> routes = null; try( jObject = new JSONObjectesonData[01); DirectionsJSONParser parser = new DirectionsJSONParser0; // Starts parsing data routes = parser.parseQObject); )catch(Exception e)( e.printStackTraceO; return routes; @Override protected void onPostEtecute(List>> result) ( ArrayList points = null; 102 PolylineOptions lineOptions = null; //MarkerOptions markerOptions = new MarkerOptionsO; // Traversing through all the routes for(int i=0;i<result.size0;i+ +)1 points = new ArrayList 0; lineOptions = new PolylineOptionsO; // Fetching i-th route List> path = result.get(0; // Fetching all the points in i-th route for(nt j=0;j<path.size0;j++)( HashMap point = path.getO); double lot = Double.parseDouble(point.getrlat")); double lng = Double.parseDouble(pointgetring")); LatLng position = new Laang(lat, Ing); points.add(position); I //Adding all the points in the route to LineOptions lineOptions.addAll(points); lineOptions.width(5); lineOptions.color(Color.BLUE); // Drawing polyline in the Google Map for the i-th route if(RoutingPl!=null) RoutingPLremove0; RoutingPl=mMap.addPolyline(lineOptions); /I I public class DirectionsJSONParser ( I" Receives a JSONObject and returns a list of lists containing latitude and longitude */ public List>> parse(JSONObject jObject)( List>> routes = new ArrayList>> 0 ; JSONArray jRoutes = null; JSONArray jLegs = null; JSONArray jSteps = null; tin jRoutes = jObject.getJSONArrayrroutes"); I" Traversing all routes */ for(int i=0;igRoMes.length0;i++){ jLegs = ( (JSONObject)jRoutes.get(i)).getJSONArrayrlegs"); List path = new ArrayList>61; I" Traversing all legs 'I for(int j=0,1gLegs.lengthaff +){ jSteps = ( (JSONObjecOjLegs.getC)).getJSONArrayrsteps"); 103 /** Traversing all steps *1 for(int k=0;k<jSteps.length0;k++)( String polyline = ""; polyline = (String)(0SONObjecOgISONObject)jSteps.get(k)).gerpolyline")).getrpoints); List list = decodePoly(polyline); In Traversing all points */ for(int 1=0;1<list.size0;1++)1 HashMap hm = new HashMap0; hm.put("lat", Double.toString(((LatLng)listget(1)).latitude)); hm.put("Ing", Double.toString(((latLng)listget(0).longitude) ); path.add(hm); } } routes.add(path); ) catch (JSONException e) ( e.printStackTraceO; )catch (Exception e)( return routes; } //Ham gi6i ma Po44ine private List decodePoly(String encoded) ( List poly = new ArrayList<Latpir 0; int index = 0, ten = encoded.length0; int lat = 0, ing = 0; while (Index < len) ( int b, shift = 0, result = 0; do b = encoded.charAt(index++) - 63; result 1= (b & OxIfi ô shift; shift += 5; . 1 while (b >= 0x20); int dlat = ((result & I) != 0 ? —(result >> 1) : (result >> I)); lat += dlat; shift = 0; result = 0; do b = encoded.charAt(index++) - 63; result (b & 0x1f) << shift; shift += 5; ) while (b >= 0x20); int ding = ((result & I) != 0 ? —(result >> I) : (result >> 1)); Ing += ding; LettLng p = new LatLng((((double) lat / 1E5)), (((double) ing / 1E5))); PolY-add(p); 104 return poly; } 5.1.8. Char ming cOp nhOt thong tin a nhdn @Override protected void onCreate(Bundle savedlnstanceState) ( super. onCreate(savedlnstanceState); setContentView(R.layout edit _layout); ed name = (EditTexhfindViewByld(tided edit name); ed_phone = (EditText)findViewByld(R.ided editphone); ed_pass = (EditText)findViewByld(Rid.ed edit _password); &confirm = alutton)findViewByld(R.idbt _edit _confirm); bt_chcmgepass = (Button)findViewByld(R.idbt_edit_changepass); bt_confirm.setOnClickListener(new View.OnClickListener() ( @Override public void onClick(View arg0) // TODO Auto-generated method stub new EditInfoTaskO.execute(""); )); bt_changepass.setOnClickListener(new View.OnClickListener0 @Override public void onClick(View arg0) ( // TODO Auto-generated method stub Intent ChangePasslnt = new Intent(EditInfo.this, Change Password.class); Bundle mbundle = new Bundle(); mbundle.putString("ipserver", ipserver); mbundk.putString("ID", User_ID); ChangePassIntputExtra("ChangePassThmale", mbundle); startActivity(ChangePasslnt); finish 0; // Bundle mbundle = new Bundle(); mbundle=getIntenta.getBundleatrarEditInfoBundle"); ipserver=mbundk.getStringripserver"); User_ID=mbundle.getStringrID"); //- new ServerConnectTaskO.executen; public String getName0 String name=null; outp.println("getname "+ User ID); try( name=inp.readLine0; I catch (I0Exception e) { 105 // TODO Auto-generated catch block //e.printStackTraceO; ) return name; public String getPhoneO String phone=null; outp.println("getphone "+User_ID); tzY( phone=inp.readline0; ) catch (I0Exception e) // TODO Auto-generated catch block lleprintStackTrace0; return phone; private class ServerConnectTask extends AsyncTctsk ( String result=null; protected String dolnBackground(String... urls) ( try( if(c1==null) cl=new Socket(ipserver,8881); outp = new PrintWriter(cIgetOutputStreama,true); inp = new BufferedReader(new InputStretanReader(cIgetInputStrecrm0)); ) catch (UnIcnownHostException e) // TODO Auto-generated catch block //e.primStackTrace0; ) catch (I0Exception e) // TODO Auto-generated catch block //e.printStackTrace0; return result; protected void onPostErecute(String r) ( new getNameTaska.execute(""); new getPhoneTaska.executer); private class EditInfoTask extends Asyncrask ( String result=mdl; protected String dolnBackground(String... uris) if(cl!=null) String tempName=ed name.getTextatoString0; Stringfi tempNames=tempName.split(" '9; tempName=""; for(int i=0;i<tempNames.lengtha++) tempNante+=tempNames[i]; if(!=tempNames.length-1) tempName+=" "; 106 try I outp.printInreditinfo " +User_ID +" "+tempName +" "+edphone.getText0 +" "+encryptMD5(ed pass.getTextatoString())); result=inpreadLine0; ) catch (lOException e) return result; protected void onPostExecute(String r) Toast malceText(getApplicationContextO, r, Toast. LENGTH LONG).show0; private class getNameTask extends AsyncTask protected String dolnBackground(String... urls) ( Name=getName0; return Name; protected void onPostExecute(String r) ( ed name.setText(r); ) private class getPhoneTask extends AsyncTask ( protected String dolnBackground(String... urls) ( Phone=getPhone0; return Phone; ) protected void onPostExecute(String r) ( ed_phone.setText(r); ) public String encryptMD5(String input) ( t731 MessageDigest and = MessageDigestgetInstancerMD5"); byte[] messageDigest = and digest(inputgetBytes0); Biglnteger number = new BigInteger(1, messageDigest); String hashtext = number.toString(16); while (hashtextlength0 < 32) hashtext = "0" + hashtext; return hashtext; ) catch (NoSuchAlgorithmException e) ( throw new RuntimeException(e); 107 5.1.9. Chtir ndng thay dal nt& khan @Override protected void onCreate(Bundle savedinstanceState) ( super. onCreate(savedlnstanceState); setContentView(R.layoutchange_password layout); ed oldpass=(EditText) findViewByld(R.id.ed changepass _oldpass); ed newpass=(EditText) findViewByld(R.id.ed changepass _newpass); ed newpass2=(EditText) findViewByld(Rid.ed changepass _confirmpass); btsubmit=(Button)findViewByld(R.icat_changepass_submit); bt_submitsetOnClickListener(new View. OnClickListenerQ ( @Override public void onClick(View arg0) // TODO Auto-generated method stub if(ed newpass.getTextatoString0.equals(ed newpass2.getTextO.toStringO)) new ChangePassTask0.executer,; Toast.makeText(getApplicationContext0, "New password is not the same!", Toast.LENGTH LONG).show0; D; Bundle mbundle = new BundleO; mbundle=getIntentagetBwidleErirarChangePassBundle"); ipserver=mbundle.getString("ipserver"); User ID=mbundle.getStringrID"); private class ChangePassTask extends AsyncTask ( String result=nulk protected Swing dolnBackground(String... urls) ( fry if(cl==null) cl=new Socket(ipserver,8881); outp = new PrintWriter(cIgetOutputStream0,trate); inp = new BufferedReader(new InputStreamReader(dgetInputStream0)); ) catch (UnknownHostException e) // TODO Auto-generated catch block //e.printStackTrace0; ) catch (I0Exception e) ( // TODO Auto-generated catch block //e.printStackTrace0; if(cl!=null) Swing oldpass=ed oldpass.getText0.toString0; String newpass=ed newpass.getText0.toString0; try outp.println("claangepass " +User_ID +" "+encryptMDS(oldpass) else 108 +" "+enctyptMD5(newpass)); result=inp.readLineQ; outp.printlnrquit); outp.closeO; inp.closeO; cl.close0; cl=null; I catch (I0Exception e) return result; protected void onPostErecute(String r) ToastinakeTexi(getApplicationContertO, r, Toast.LENGTH LONG).showQ; I 109 TM LItU TRAM KHAO [1] Trucmg Thi Ngic Phuong, Ltip trinh Android, NM xuat ban thai dai, 2012 [2] Ed Burnette, Hello Android, The Pragmatic Programmers, 2013 [3] Wei-meng Lee, Beginning Android Tablet Appication Development, Wrox, 2012 [4] Lauren Darcey va Shane Conder, Android application Development, Sams, 2013 [5]Barry Burd, Android application Development For Dummies, 2012 110

Các file đính kèm theo tài liệu này:

  • pdfkhoa_luan_tim_hieu_dich_vu_google_map_xay_dung_ung_dung_chia.pdf