Luận văn tốt nghiệp: Tìm hiểu và phát triển ứng dụng tra cứu thông tin tàu - xe trên thiết bị di động sử dụng hệ điều hành Android

506 1

Miễn phí

Tải về máy để xem đầy đủ hơn, bản xem trước là bản PDF

Tags: #luận văn#luận án#đồ án#tiểu luận

Mô tả chi tiết

1. Mở đầu

Trong 20 năm trở lại đây, thu nhập bình quân đầu người Việt Nam đã tăng gấp 3 lần kéo theo việc gia tăng phương tiện cá nhân và sự phát triển của hệ thống vận tải công cộng. Trong đó vận tải công cộng bao gồm, đường bộ, hàng không và đường thủy là xương sống giúp lưu chuyển người và hàng hóa nhằm duy trì và phát triển kinh tế. Mặc dù có tầm ảnh hưởng quan trọng đến sự phát triển kinh tế nhưng hệ thống thông tin hỗ trợ nhu cầu theo dõi lịch trình của tàu, xe buýt hay tìm đưuòng đi giữa các bến... lại chưa phát triển tương xứng.

2. Nội dung

2.1 Tổng quan về dự án

Khảo sát thực tế

Giải pháp

2.2 Phân tích yêu cầu bài toán

Mục tiêu

Yêu cầu kỹ thuật

Yêu cầu nghiệp vụ

Ánh xạ yêu cầu nghiệp vụ và chức năng

  • Sơ đồ hoạt động của chức năng Giờ tàu
  • Sơ đồ hoạt động của chức năng Tuyến buýt
  • Sơ đồ hoạt động của chức năng Chuyển tuyến
  • Sơ đồ hoạt động của chức năng Định vị và Bên xe buýt

Kế hoạch dự án

Đặc tả chức năng

  • Chức năng Giờ tàu
  • Chức năng Tuyến buýt
  • Chức năng Chuyển tuyến
  • Chức năng Định vị
  • Chức năng Bến xe buýt

2.3 Thiết kế và triển khai

Hệ điều hành Android

  • Giới thiệu
  • Kiến trúc hệ điều hành Android

Chu trình sống của một ứng dụng

  • Activity là gì?
  • Chu trình sống của một activity (Activity lifecyle)

Kiến trúc mạng

Mô hình hóa dữ liệu

  • Sơ đồ cơ sở dữ liệu
  • Cấu trúc các bảng dữ liệu

Triển khai

  • Cấu trúc của một project Android
  • Cấu trúc của file AndroidManifest.xml
  • File R.java

​Xử lí dữ liệu đầu vào

  • Xử lí thông tin giờ tàu
  • Xử lí thông tin tuyến buýt

​Cài đặt các chức năng chính

  • Chức năng Chuyển tuyến
  • Chức năng Định vị

​Cấu hình

3. Kết luận

Mặc dù phải tự tìm hiểu về một khái niệm hoàn toàn mới là hệ điều hành Android, nhưng tác giả đã cố gắng nghiên cứu và trình bày một cách chân thực nhất những hiểu biết của mình về các vấn đề có thuộc khuôn khổ của khóa luận này. Với tính năng Chuyển tuyến, do lí do khách quan là không thể tìm được bộ dữ liệu chi tiết về khoảng cách giữa các tuyến nhưng tác giả đã hoàn thành phần này theo hướng tìm ra cách di chuyển giữa 2 bến xe buýt mà số lần chuyển bến là ít nhất, đồng thời cơ sở dữ liệu được thiết kế theo hướng mở (có trường Trọng số), trường này sẽ phục vụ cho việctính toán chính xác cách di chuyển ngắn nhất vào khoảng cách giữa các bên nếu có được dữ liệu chi tiết. Bên cạnh đó, tính năng Định vi cũng đem đến khả năng mở rộng cho chính nó. Vì hoạt động dựa trên Google Map API và Google Play API nên khả năng bổ sung các tính năng mới là rất khả thi và hai API này được cập nhật thường xuyên nên khi được mở rộng tính năng này sẽ có khả năng đáp ứng được yêu cầu của người dùng.

4. Tài liệu tham khảo

Quyết định số 1327/QD-TTG, Quy họach phát triển giao thông vận tải đưuòng bộ Việt Nam đến năm 2020 và định  hướng đến năng 2030, Thủ tướng Chính phủ.

Nguyễn Việt Cường, Tuyến bus Hà Nội, Trường Đại học Công nghệ - Đại học Quốc gia Hà Nội, 2012

Trần Xuân Bộ, EBUS 2.2 - Phần mềm trợ giúp đi xe Bus tại Hà Nội và Hồ Chí Minh, 1/2010...

Nội dung

BQ GIAO DIX VA DAO TAO TRISONG Dip HQC THANG LONG --4•41613/6.6-- KHOA LUAN TOT NGHIEP TIM HIEU VA PHAT TRIEN eNG DUNG TRA CirU THONG TIN TAU - XE TREN THAT BI DI BONG SU' DUNG HE DIEU HANH ANDROID GIAO VIEN HUIJNG DAN SINH VIEN THVC HI$N MA SINH VIEN CHUYEN NGANH : THS. LE MINH TUAN : NGUYEN HOANG LONG : A10805 KHOA HQC MAY TINI1 HA - 2013Hg thong tra tit thong tin tau se Nguyen Hohug Long A10805 Myc Lyc DANH MVC HiNH ANH - BANG BIEU 1 DANH MVC VIET TAT VA THUAT Nal 2 Lim mer DEU 3 CHVONG 1. TANG QUAN VA Dv AN 5 1.1. Khio sit thyc td 5 1.2. Gill phip 7 CHUONG 2. PHAN TICH CAU BA! TOAN 8 2.1. Myc lieu 8 2.2. Yen au ky thui)t 9 2.3. Yen cAu nghiep vg 9 2.4. Anh yen cAn nghiep vg vi chit nang: 12 2.5. DO ti he thong 13 2.5.1. Sc dd hogs &Ong ctia char nang tau 13 2.5.2. Sc dd hoot clang czia char ?Ong Tuyin buys 13 2.5.3. Sc dd hogt tang clia char nang Chuyin tuyin 14 2.5.4. Sa rid hoot clang caa chic nang Dinh vi va Bin xe buft 15 2.3. Id hottch dy in 15 2.6. Dtc ti chic 'ling 16 2.6.1. Char nang Gid tau 16 2.6.2. Char nang Tuyin buft 18 2.6.3. Char ?Ong Chuyin tuyen 21 2.64. Chtiv nang Dinh vi 24 2.6.5. Cluic nang Bin xe buYt 27 CHUONG 3. THIET KA VA TRIEN KHAI 31 3.1. He diAn hanh Android 31 3.1.1. Giti thiiu. 31 3.1.2. Kien truc hi diJii hanh Android: 32 3.2. Chu trinh sting cia met Ling dung 33 3.2.1. Activity la gi? 33 Khoa lutin tot nghiepHe thong tra min thong tin du xe Nguygn Holing Long A10805 3.2.2. Chu trinh sang ctia tWat activity (Activity lificyle) 33 3.3. Kien triic m;ng 35 3.4. Mil hinh h6a de lieu 36 3.4.1. Sa dd co so. die' lieu 36 3.4.2. Cciu true cac bang dii lieu 37 3.5. Trien khai 38 3.5.1. Cdu &tic ctia mOt project Android 39 3.5.2. Cciu trac act file AndroidManifestxml 39 15.3. File ltjava 41 3.6. Xir ly dils lieu diu van 42 3.6.1. Xa lit thong tin gier tau 42 3.6.2. Xtelj thong tin tuyin bujt 44 3.7. CM d#t cfic chin ning chinh 48 3.7.1. Char ndng Chuyin tuyin 48 3.7.2. Chtic ming Dinh vi 51 3.8. Cliu hinh 54 CHIMING 4. KiT LU#N VA HUI6NG PHAT TRIEN 55 Puy LyC 1 - CAC THU3T NG* 56 PHy LyC 2 — DANH MyC TAI LIeU TRAM ICH10 60 Khasi lu#n tat nghiepHg tilting tra cum thong tin tin xe Nguyen Holing Long A10805 DANH MI,JC HiNH ANTI - BANG BIEU Hinh 1. 1. Da lieu gib tau don bang 5 Hinh 1.2. Da lieu gib tau (Jong anh 6 Hinh 1. 3. Der lieu tuyen bukt (long web (lief ke) 6 Hinh 1. 4. Da lieu tuyen bukt dong web Wong bang) 7 Hinh 2. 1. So de USECASE tha ting dong 11 Hinh 2. 2. So de hoot dong tha chirc nAng Gib tau 13 Hinh 2. 3. So de' hoot dOng dui chirc nang Tuyen buyt 13 Hinh 2. 4. So de hoot dOng dm chirc Ming Chuyen tuyen 14 Hinh 2. 5. So de hoot dong coca chat nang Dinh vi va Ben xe buSrt 15 Hinh 2. 6. Ke hooch do an 15 Hinh 3. 1. Kien true he dieu hanh Android 32 Hinh 3. 2. Chu trinh song eau met Activity 34 Hinh 3.3. Kien true mong 36 Hinh 3.4. So de co so der lieu 36 Hinh 3. 5. du true met project Android 39 Hinh 3. 6. Minh Ilea cAu true file du viva 43 Binh 3. 7. Quy trinh xir 19 thong tin gib tau 44 Hinh 3. 8. Minh hoa LookUpTable 47 Hinh 3. 9. So d6' hanh dOng chire nang chuyin tuyen 48 Hinh 3. 10. Minh hea mo hinh him du lieu 49 Hinh 3. 11. Cac 16p he fro thuAt town Dijkstra 50 Hinh 3. 12. LA'y debug keystore 52 Hinh 3. 13. Lay API key 52 Bang 2. 1. Bang anh xo you eau nghiep IN vi chile rang 12 Bang 3. 1. Loge sir phat trim he dieu hinh Android 31 Bang 3. 2. Bang dot lieu tuyen xe buSrt 37 Bang 3. 3. Bang du lieu de doon dm tuyen xe bukt 37 Bang 3. 4. Bang dfr lieucac bin xe bukt 38 Khoo lutin tot nghiep Trang 1Hg thOng tra cvu thong tin tan ice Nguyen Holing Long A10805 DANH MVC VIET TAT VA THIJAT Nctr Tir viet tat Ten tieng Anh day &I Ten tieng Viet day du UC Usercase Chin nang API Application Programming Interface Giao dien lap trinh img dung CSDL Database Ca kr du lieu HTML Hyper Text Markup Language Ng8n nga hien thi sieu van Mn SSL Secure Sockets Layer Server May chii Khoa lutin Mt nghiep Trang 2Hg timing tra ctiu tilting tin thuxe Nguyen Holing Long A10805 LEI 11169 DAU Trong 20 nam fro. !di day, thu nh#p binh quan diu ngu&i Gila Viet Nam da tang gip 3 fan keo theo viec gia tangphucmg fien ca nhan vi sv phat hien dm he thong von tai eating cOng. Trong do van tai &Ong cOng bao g6m, duang b0, hang khong va duang thity la xucmg sling gift') Iuu chuyen ngu&i va hang h6a nham duy tri vi phat trien kinh Theo quy hoach phat trien mpg Itred giao thong cua Chinh + Giao thong throng sat: Den nam 2020: giao thong von tai duang sit can chiem taing t6i thieu 13% ve nhu cau luan chuyen hanh khach va 14% ve luftn chuyen hing hoe trong ding khoi hrqng van tai cua town nganh giao thong van tai; trong da van tai hanh khich do till bang duang sat dat it nhAt la 20% nhu au van tai hint' khach Ong cOng tai Thti do Ha Nei vi thanh phi) Ho Chi Minh. + Giao th8ng dueng be: Giai dodn den Mm 2020: Ithei hrqng khach van chuyen 5,5 tS, hanh khach vai 165,5 tS, hanh Ichich luan chuyen.lChei luqng hang has van chuyen 760 trieu tin yea 35 tjr tin hang h6a luan chuyen. Phucmg tien 8 t8 cac loai khoang 2,8 — 3,0 trieu xe. Qua cac mvc tieu phat trien tren ta thiy dtrqc vai trd quan tong cua van tai duang sit va duang be trong hien tai va twang lai. Mac du c6 tam anh huang quan tong den su phit then kinh to nhu v#y nhung he thong thong tin he trq nhu cau theo dei ljch trinh cua tau, xe butt hay tim duang di gifts cac ben...lvi chua phat trien twang ximg. Ben canh do, mac c111 mai buck vito thitrtrangvio nam 2007 nhung tec de phat trien ala smartphone (Dien thoai thong minh) va tablet (May tinh bang)da tien gin tai v1 tri dm may tinh yen da phat then truerc d6 30 nam. Rieng yeti smartphone, nam 2012, luqng thiet 1)1 ban ra da dat han 600 trieu, met con s6 dang ma trac dei vai cac nginh khac. Se lieu My cling duqc khAng djnh khi so sanh Wang quan vai cac thiet bi ket ninths Microsoft: tong chiem tren 80% nam 2009 (Windows, Windows Mobile) nhung tinh den than 3/2013 chi con dued25% do sv xuit hien citaiOS va Android. Qua d6, ta thiy sv bung no manh me dm thj throng thiet bi di (king va day thvc sv la xu twang phat trien tha Wang lai. Dfra vao cac yeu t6 neu tren, em da quyet djnh Iva chqn de tai "Xay dung he thimg h6 trq tra cuu thong tin tau xe tren nen tang di tieing Android". Sr thanh cling dm de tai Kb& lutin hit nghiep Trang 3Hg thOng tra eau thong tin tau xe Nguyen Holing Long A10805 mang lai cho cong ding met img dung co tinh thgc tien cao, gitip ngueri sir dung c6 them cong cu de tra cau thong tin ve tau xe a-mg nhu tim duerng di gifra tic ben met cach thuon tien, giap giim thai gian vi chi philim tang chit lugng cuOc song. Nei dung dm tai lieu nay dugc to chat thinh 4 chtrcmg: Chuang 1: Tang quan ve du an. Chuang 2: Phin tich yeu cAu bai town. Chuang 3: Thiel ke va trien khai. Chuang 4: Ket va huemg phit trien. Lip trinh ling dung cho thiet b1 di dOng dtra trEn nen tang Android !wen la met mirth dAt mAu ma cho cat Ip trinh vien. Do lam viec dec lip, kien that con han the nen trong qui trinh thgc hien de tai khong Hardt khei nhang thitu sot. Em rat mong nhon duct sg eking gap, chi bio caa cat ThAy, Co de em co the hoin thien hen ling dung, dap ling clugc phAn nio nhu clu ve cic ling dung co tinh dart tien cao trong cuOc sang. Met fin nUa, em xin chin thanh cam an Ha ngay thang... ...Warn 2013 Sinh vien Nguyen Holing Long Khoo 14n tot nghiep Trang 4'INN I h•• LnI n 106 .1 rUN J D I et 1,,i iNJll Tlir hiy )3.11.181: ) I ;AM I rs • co du td auk s civic nano nhen iu s ogAnn ITO / goy tr/Vs phi trk HO tic quacti •Diu W.:Van •l•ez co% vi) -114-91 ba +1NN - Tbci- ea OF 31651 twirls] •.pletC11110 1411111 m web Net •an tanisms anon. n. m 1.114( t'll.l liI* Hg thong tra cum thong tin tin xe Nguyen Holing Long A10805 CHUONG 1. TONG QUAN Ve Dv AN 1.1. Khao sit thvc to O theri diem hien tai, da eó nhung img clung ho trq ngueri dung tra cfru gib tau, xeb4t nhu sau: Theo dOi gib tin qua chfrc nAng "Xem gib tau" tai dja chi: http://www.vr.com.vn/gio-tau.html (Bio DSVN thiet ke vi quail Hinh 1.1. DO. lieu gib tau clang bang Khoa luOn tot nghiep Trang 5Nguygn Holing Long A10805 He timing tra cam thong tin tau xe http://vetau24h.com 0 at Liu Me. Mu 551 0 ad du eta T •at Gm Hee Thu 515 0 ad tiu Ilta Tao Sr teu NU Tau TM •ais tiu IN. Thu 512 •at au Pita T lu 554 0 ad thu nea Thu 5E6 •at flular• Thu 5E15 ab tiu Moo Tau 1162 •Stt Thu Fnanb mac •5,2 Thu mho.* scat ▪SET V. Mato MN•sa •004 tau nhanh m141 nth •II3 Thu dtrn ms •5E0 Tau aim seth •set Thu nhamh m•sa •sta tau mhaah se.. •flit Thu chirn nha mast •7111 Thu ch$rn nha ma. e2t pane Sem Na na past 41141 04 an ml qui kat, ka naPS n du out khan. mule • reP III rt. 060 (th Iheah 116a tie xuit ph& 4 ga Hi nti uh ga din kb ea list MM. Gad dia. ell Mt le pd au din all Pd 6 01 mil ea one 40.4 Idle. kill Chan. Vi du nIu nui Wick mufti& thy tie a Thank Hos Mi POW 66,16 22h15 N liu si Wag 4 Ofy 3 460 vs nun p-it ks 32h111. nano 66 vea a Hi a ul 64 tla writ ph*, Ge 5G ean la es ad any nin 9a dim vi garb elm Sea Gin lenh Thrh Hal 104 87 175 Gel dIn 21136 72:15 11 20:30 22313 Vth 319 I 0144 00:49 DEng Ila 5:2 0431 04:43 De/9W 622 06;43 . _ . 06:46 HUI 6813 D757 03132 OA PSG Al 10.31 10:46 Tan Kt 865 ' 12135. 1203 GUhrc NO 928 1330 1131 Mu Td 1006 16.16 16:33 API Hai 11913 • 11133 1836 Mu Tract 1315 10:28 3133 Thlp Chkn 1403 22134 22137 Si Gin 1726 0430 04:10 Hinh 1.2. Der lieu gib tau clang anti + Danh sach cac tuyen xe butt va cac diem dimg duct lief ke a dang text http://www.xebushanoi.com/forum/showthread.php?t=1267 (co chirc nang tim du6ng nhung khong hoar dOng) 03. Ben xe GLip Bat - Bin xe Ga Linn Tin wit 10 -15 phit/chuyin TAN Own hart 6Ing: MOO 211901 LO Binh: LAIL a: pins cap eat - Gob Phone L• Du& - Rowan Thong thin • vo cau- Trim Ikp ENO - Trim paw) Obi - Trin 11146 Duk (Duey nu Dude OE Hang Moat ) - Nguyin Via (ft - 99o/40 GM • aux lin - 11g6 Gm Pim Den No Ge Oen. 1.11101 ye: bin n Go Lien - Ng& Gu Khim *pc Urn Nguyen VIn C0 Tin NMI Pa (Quay 61121 Wok phi Hing Msw ) - Trio Pang 100 Trim Minh Pr - Trim HS, Doo - U Dull - Gab Vag - NO 3 0061 CI- pins Gidp tlu 03B. BX Gap Bet - I®T ViOt Hutig, Vhcom Village The wilt 25.30 phOLichuyin Tel gts• Mgt ger Slue: Diu A01120- 01110, Diu 0: 61100 - 01120 Tro: Nu A: 11600 121150, DU 0: 111110 - OHIO Wu: Diu A: 1930- 19150.05u I: 161 50 201910 131 3.0001/1 190 LO Ludt di: ex 048 BY- GS a16rg - Li OUP Itmin Thane Him Ti eau Trio Ming Doc -Tan 0691 Dv Trim pang Trio MIS Pit - Long Mn. (Dam Pao Au Mt& phi Ming Moos) au CM/n5 WOG - Nguyio Van - 11g6 GS Nproln Coo Look nhi P3 SOT V41 HUN - Dw Green Noun- Tnieng Urn - Viacom Wage (TT Mahe Mel NEM Centre, Long Bin) Hinh 1.3. Da lieu tuyen butt clang web (lief + Trang web dm Cling ty Van tai va Dich vp eking Ong Ha Nei (co chat tim &ring nhung kitting float dOng) Klioa loan tot nghiep Trang 61.0 TRINH CAC TWIN XE SUtT THANH P145 HA Nol rte. mita ffitri C1M1 NOV e0e0 TAM suati Hoe 0000 1.11122 DI WA CAC odtsc Pad 1:01n0 Hap V0 QUA CAC otrenc otth abet se ii$u natio use a (Y20 Dee aim a Ya MIS. ra-C, Opal 2/ an Pau - Dan tuna Outten 6 ' 68 2. Quang -(00 Ban Haw Din Truna;Ha 06a2) - Tan Hang - ing GI • King Da/ M - Wenn PD2 06,12.2 hOunin That • Ras Doan Trb. Hai Dr Sc • Th Son Tub Qt.& Da - Ha ea Kixam,Htcy Th.,. La Cult. Dan• Nauy:incition/63Bins t.as - xi -Locna aka - Tly Sal • W se . mar 417, nob a Dan 2 - AliTrio - Din au 00 Han Tel Hana0 - Gana iyirgao; Qua/140616. Wagn 1:2 11.mIngTrm wr.041.10-aoret• 9.06- ZOO. 10 -15 phi/tic/ay& rallisbiza alias 01 LO tank tic win Ise butt HIMOIBUS ..S7ANOIBUS ( bung buoy than!! Hg thong tra ciru thong tin tau re Nguyen Holing Long A10805 ▪Tay dal Was •GM Calm ▪Co au 12 that •Dith Wing pail WM a TC Ms Saba •L.1ah la4a •C/6 law •Dag 10 thing •Tat - NCI WY a Hang din C NHp tan Wang hila •Havaill ‘ifc Wag dm lila cilia Ityise 114 Hinh 1.4. Dff Feu tuyen but (long web (clang bang) Qua nhUng vi do tren to thay,thong tin ve gitr tau hay cac tuyen xebu9t da dugc quan tam phat then nhtmg van dang a (long rat don giitn (Het ke, anh), hoac chirc nang tim dutmg giffa cac tuyen bu9t 6 Ha Nei da co nhtmg kitting hoot dOng. Viec nay gay tang phi thai gian khi ngutri dimgchi mu6n tra ciru gig tau gift 2 ga cg the hay tim du?mg gift cac tuyen bu9t.Ngoli ra, neu mutm tra ciru, ngtrai &mg phai sir citing may tinh ca nhan va co ket mil Internet meri thut hien duqc. Hon the nay lam giam t6c do Mu thong ciia ngutri va hang h6a, vi khong phai luc nao cling co sin may tinh co ket n6i Internet cling nhu cac trang web nay kh8ng phai luc nao ming sin sang dap terng (trailing hqp trang web gap su c6).Do do, giai phap dua cac thong tin nay len thiet hi di dOng se khic phoc duqc diem yeu nay. 1.2. Gild phip Vi dft lieu ve gig tau (lien quan den cac tuyen, ga vi gib tau) co tinh 6n dinkit co str thay d6i trong nhieu nam. Hay du lieu ve cac tuyen but cling it thay d6i trong nhieu thang. Vi vay, viec xay dung mOt Ong (long cho phep tra ciru cac th8ng tin nay tren cac thiet hi di dOng choy he dieu hank Android 11 mOt giiti phip dot duqc nhieu uu the: Theo s6 lieu cim IDC: tinh den qu9 3 nam 2012, he dieu hanh Android da chitm 75% thi phan smartphone tren toan eau, khang dinh tinh ph8 hien cim he dieu hanh nay. Nguan dimg có the flip can cac du lieu nay mgi Mc, mqi noi do img dtmg nay duqc phat then cho cac thiet bi di dOng. 'Chong that thiet phai c6 ket n6i Internet mai c6 the tra cirudtrgc, vi cac dft lieu nay la on dinh trong mOt khoang thbi gian dal va co the duqc luu tit offline. Khasi lu(in tot nghiep Trang 7He thilng tra torn thong tin tau xe Nguyen Holing Long A10805 CHUONG 2. PHAN TICH YEU CAU BA! TOAN 2.1. Muc tieu De xay thing duqc met Ong clung hat' ich vi phu hqp yid de tai dot ra thi img dpng nay phai dpt dtrqc cac mpc tieu sau day: —Cho phep ngutri dung xem th6ng tin chi tiet ve gier tau xuAt/den met ben, trong met tuyen tau niun trong hg thong von tai hanh khich dutmg sat dm Viet Nam. Th6ng tin nay phai bao g6m oTuyEn tau: ten tuyen. oMa tau: mOi tuyen lai c6 nhiau tau WA ma khac nhau. oTen ben-gia tau: mOi tau duqc phan biet btri ma tau Ipi di qua cac ben khac nhau, gitr den/xuat ben cling khic nhau. —Cho pile') ngutri dung xem thong tin chi tiet ve cac tuyen xe butt thuec he thong xe but nOi d6 thanh ph() Hi Nei. Cac thong tin nay bao gem oDanh sach tuyen xe buyt: phai co day di, thong tin ve cac tuyen buyt nOi do that'll phi) Hi Nei duqc Clang tai tai dja chi http://www.transerco.vn, bao gem ten tuyen vit ma tuyen. oChi tiet tuyen: bao g6m ten cac ben Ian Itrqt theo chiEu di hoOc chiEu ve cua moi tuyen. —Cho phep ngutri dung tim Wang dan chuyen tuyen gift hai ben bit ki trong he thong tuyen xe butt nOi do thinh ph6 Ha NOi. Tnrimg hqp co hueng dan chuyen tuytn phi.* hqp, Ong dung phai hien thi hutrng dOn 46, can nguqc lai thi phai co thong bao kheng co hutrng dan phu hqp. Thong tin chi can can bao g6m: oTen ben: la ten cita ben ngutri dung can len hoOc xueng xe buyt. oMa tuyen: la ma s6 cua tuyen img vOi ten ben ben ngutri dimg can len hoOc xuang xe butt. oTen tuyen: lit ten dm tuyen xe butt img v6i ten ben ben nguiri dung cirTh hooc xuting xe butt. oHuang &An: la chi dan cho ngutri dung biet tai moi ben hp can "len" hay "xu6ng"xe. —Ho trq ngutri dung de hp biet duqc vj tri hien [pi cua minh, deng thoi tim kiem vi hiEn thj cac bEn xe butt gAn yeti vj tri hien tai cua ngutri dung tre'n ban de tren ban d8 sti(Google Map). Cac thong tin hien thj can bao Kim% lutp tot nghiep Trang 8Hg thOng tra cum thong tin tau xe Nguyen lining Long A10805, oDinh &au vi tri hien tai cua ngtrei dung va ten ciia vi tri c16. oDinh dau vi tri cac bin xe butt Ian vi tri hien tai va thong tin ye ten dia diem gin yin cac dinh diu do. 2.2. Yen cAu ky thuOt De tri thanh met san phArn co tinh thyc te, h6; try tot cho nhu cau caa ngtred dimg thi img ding phai dat duqc nhung yeu au ky thu#t sau: -Ve chnc nAng: oCac chirc nAng phai duqc phan chia n3 rang, co the hoot dung &X 14 ma khong an dya vio cac chirc nAng khac. oTec dg xir 1st yeu cat' phai nhanh va on dinh -Ve giao dien: oClang dyng phiti hien thi duqc ten tit cac cac deng din thoai co cau hinh duqc dua ra i myc 3.7 oCac thAnh phan hien thi nhu th8ng bio, danh sach, ban d6...phai re rang, der dyc, theo del -Ve kha nAng cop nhat o(frig dyng phai dam bao kha nang cop nhot dix clang khi c6 cac thay &Si dm nguim de lieu nhu thay del 10 frinh tuyen butt hay de lieu ban de Google Map... 2.3. Yen cau nghiep vy Sau khi dimh gia va phan tich hien tong ciut ac ting chmg tat thi truOng khi giai quyet yeu au cho bai toan nay, img dung can phai co duqc cac yeu au nghiep vy nhu sau: BR1: Xem gib tau di/den ben Try giap ngutri dung theo dbi gin tau xuat/vao cac ben thuOc met tuyen cu the. Doi tuqng sir dung: ngtrei dung au cu6i Cac thong tin can quan ly: -Ten cac thy& tau thuOc he thong dueng sat van tai hanh khach dm Viet Nam -MA cac tau img vii timg tuyen, thong tin ve gib tau img yeti m61 ma tau BR2: Xem thong tin tuyen butt Cho phep ngtroi dimg xem cac tuyen xe butt thuOc he thong xe butt nOi do (Ha NOi), dua ra danh sich cac ben theo trinh ty chitu dive (mg vii in& tuyen. DM tuqng sir dung: ngtrei dimg dau cuiii Khoa loan tot nghiep Trang 9Hg thOng tra cam thong tin tau xe Nguyen Hoang Long A10805 Cac thong tin can quirt' 1±: -Ten, ma the tuyen xe butt thuOc he living xe butt nOi do Hi NiO -Ten cac ben thuOc met tuyen, trinh tSr the ben theo chieu dive BR3:Xem burin den chuyin tuyen xe butt 16 trg nguOi dung tim ra met phucmg an chuyen ben it rill& de di chuyen giaa hai ben bat ki bang xe butt. D6i tugng sir dung: ngu&i dimg diu cu6i Cac thong tin can quan 1Y: ttrcmg to nhu BR2 nhung b6 sung them thong tin ye khoang cach giita cac ben. BR4:Xic dinh vj tri hien tai tren bin do SO Dinh dau vj tri hien tai cim nguiti dimg tren ban d0 sr') kern thOng tin ye dia chi cim vj tri do. Doi tugng sir dung: ngtroi dung dau cu6i Cac th8ng tin can quin 1Y: -NOi dung hien thj Ye (Ili diem hien tai BR5: Tim cac ben xe butt gin vj tri hien tai Dinh dau cac ben xe butt gin yeti vi tri hien tai cim ngutri cling kern theo thong tin ve dja chi cim cac ben d6. D6i tugng sir dung: ngutri dimg dAu cuti Cic thong tin an quan -Bin kinh tim kiem bet xe butt gat nhat Thong tin ye dia diem dm cac ben xe butt dO Khasi luau tot nghiep Trang 10HO doing tra dru thong tin Mu xe Nguyen Holing Long A10805 Su do USECASE Ngverl dung HInh 2.1. Su de USECASE cua (mg dung Cic tic nhfin: Ngirtri dung: la tic nhin chinhsir dung cac chic ning cua chuong trinh. Google server: la he thong ben ngoai cung cap dCt lieu de cac chic rang lien quan co the hoat dung. Cic chin Sing: UC #001: Gib tau Chit fling nay cho phep ngutri ding theo del bang gib tau cila met tuyen nhat djnh, bao gem ghat tau xuAt ben hoac den ben. UC #002: Tuyen butt Chit ning nay gulp ngutri ding xem thong tin chi tiet dm met tuyen butt, bao gem s6 hieu tuyen, ten tuyen, liet ke cac ben theo trinh tu chieu dive. UC #003: Chuyen tuyen Chic ning nay se ho trq ngutri ding tim ra met phucmg an chuyen tuyen xe but non nhit giOu ben diu va ben cuei do ngutri ding nh$p vio. UC #004: Dinh vi Chirc ning nay cho biet vi tri hien tai cia ngutri ding tren ban di) so (Google Map) va dia chi cia vj tri do. UC #005: Ben xe butt Chic ning nay se danh diu vi tri the ben xe butt On yeti vi tri hien tai cia ngutri ding kem theo dia chi dm the ben di tren ban de s6 (Google Map). Khea lutin bit nghib Trang 11Hg thOng tra cum titling tin tau xe Nguyen Holing Long A10805 2.4. Anh xy yeu au nghitp vy vh chat ning: BR BR1 M8 ti Xem gib tau di/den ben UC UC#001 BR2 Xem th8ng tin tuyen butt UC#002 BR3 Xem huong an chuyen tuyan xe butt UC#003 BR4 Mc dinh vi tri hien tai tren bin cth s6 UC#004 BR5 Tim eac ben xe butt gait vi tri hien tai UC#005 Bang 2.1. Banginh xa yeti eau nghiep via va chat nang Khasi Juan tot nghit'p Trang 12Hg thOng tra cut thong tin tau xe Nguyen Holing Long A10805 2.5. D# ti ht tilting =So do hogt citing can char ning Giel tau So ob hoot Jong grits' dung Chuong trinh Database RN RID DiOn Chit 0.01 ifiel this.* or •Gliv tie ' l Ir0" L-... skt twin awn min Lb ma or Chen mit -ruvei Ise __il aTnikkiltdia. H —• Hies *4 darn Yd SI tis Chon nik •4 Our non ed kid lb 4:44:th" —0 Win III bk. 110 tlu Sit Hinh 2.2. Sa do hoot dOng cub chin nAng Gil)* tall =Se do hogt dOng cria chirc fling Tuyin built soda hoot dOng Ngubi clang Chuang trinh Database 7 non dirt nIng <.M, sick twin quyIn bee illy I'M Po de •Twolln bvir Chun 11.00 wen dl re Oen 11. tlft byte' 04n not ea.. CPChaly a' „MOM rich bin Owe et bah S. bin bib 'titer, cant' ' ( la Pa ) Hlnh 2.3. Sa do host deng cub chirc nang Tuyen but Kit& loan tat nghib Trang 1311g thing tra cum thong tin tau lie Nguyen Holing Long A10805 aa do hopt ttit'ng ctia char nang Chuyin tuyin Su (lb boat (tong Nguti dung Chuang binh Database [ upArn upAnto I ... Kien the giso dam tin* twin' Ova dot Moe TWAT, twin" *So In Bin* crone • 004V bln dr 4 crone 'NhIp So din• —I—. %a sin din t• 7 bins Ow tin tin awn nOt "ern' 167 Thong Min ins Mary diacherfin twin than' We Hinh 2.4. Sa dill hoot dOng cua chic nang Choy& tuyL Khoa luCin hit nghiep Trang 14Hg thOng tra cum thong tin tau xe Nguygn Holing Long A10805 co di hoer erg this char ndng Dinh vi va Bin xe butt sa ab bon ging Ngutri dung Chuang trinh Database In yulG cluk nary ChTh "DOW' ( Lfr olCallsbindb DI chwda the' .1 tri Mtn tal Gm* Mobs, Illfat this is bin ObfreltAbeltIa I.3 Mon nut 'BM xe bur Lit Oil WO, Mx tin,. wittier' Id was Sin is eit No bin a tin se buil el wl tri ItIn Iii . at St z Hinh 2.5. Sc, do host dOng cua chfrc ang Dinh vi va Ben xe butt 2.3. ICE hoach dg in DE da an dam bao tiEn dO nham cho ra san pharn dat duce the yeu cau da dE ra, dual day la bang ke hoach chi tiet tang giai doan ctla da an. STT Ten he hoach Thai gian 1 Kited tao du an, lap ke hoach that hien da an. 2 ngay 3 Phan tich yeu citu chirc nang, dua ra mo hinh va luting ding vi'ec tong quan. 1 tuan 4 Thiel kt m6 hinh UC va disc to cic chat nang he thong. 3 tuan 5 Thiet ke CSDL. 5 ngay 6 Thiet ke giao dien he th6ng. 3 tan 7 Lap trinh. 4 thing 8 Kiem this timg giai doan. Theo tan 9 Kiem this sau !chi he thong hoan thinh. 1 tuan Hinh 2.6. Ke hoach da an Khoa lui)n tin nghiep Trang 15He thong tra coy thong tin tau xe Nguyen Hoang Long A10805 2.6. I4c ti chat ning Char tang Gib tau UC #001 Gib tin DOploic top: thip Moto Chirc neng nay cho phep ngtrtri dimg theo deli bang gill tau caa mgt tuyen that djnh, bao gam gib tau 'cu& ben hoec den ben. Tic nhin Chi:1h Ngubi dimg Phy Khong co Tien dieu ki%n , !Chong co Hon dial kien Think cong . Hien thj danh sach ben tau va gib tau Wang Ung Lai Th6ng bio 181 va gift nguyen giao dien Gib tau D4C TA CHilt NANG Luang sly kitn chinh/Kich bin chinh User case nay bat dau khi ngutri den main xem gib tau rai/xuat ben dm the ben thugc mat tuyen cv the. 1.Ngtrai dung chgn chirc neng Gib du. 2.fing dung se hien thi giao dien cho phep ngtrai dimg chgn Tuyen tau,MA thucen tra cau . 3.Ngtrtri dung chgn ten my& tau can tra ciru. 4.L'Ing dung lay du lieu gib tau dm me tau Mu tien thuOc tuyen tir Ca set du lieu sau dO, hien thi danh sach ben tau kern theo gib twang img. 5.NO:7i don chgn Ma tau mong mueintrong danh sach gib tau. 6.CEng dung lay de lieu gib tau dm me tau dugc chgn tir Ca so du lieu sau do, hien thj danh sach ben tau kem theo gib Wang ling. Luling str Mtn phit sinh/ Kjch bin phit sinh 1. Ngooi lie khong tan toi Ca sir der lieu Gib tin 1.1.1"ing dung thong bao "IChong co ca sa de lieu Gib tau". Khea luau tot nghiep Trang 16Nguyen Holing Long A10805 11§ timing tra cvu thong tin tau ae Giao din minh hos Tuygn thu — OW Wit — 0 .. ® WO - sir can Q _ • Tuygn tau Ski GM -HOW 0 - ,.. 1 Ma tau Ski Um - Hi NO 0 Hi 801 - 1.80 Eai 0 Lb Csi - 14a NOI 0 Hi NOi - Hi Phbng 0 Nil Phbng - Ha NOE 0 Mii tau i 8E2 0 Sa do trinh ty (Sequence diagram) ActivityTrainSchedule DAO Database gill ChonTuyen() Pi YeuCauDuLieu() 'HlenThiDanhSachTuyenTau() ChonTenTuyeno ) 4 ChonTau() HlenThIDanhEachMaTau() ChonMaTau() .4_3 YeuCauDuLleun 10 4HlenT11BanaGloTau0 TratalDuLleu() 4 User ActivityTrainSchedule DAO Database Sa dli lop chi tat (Class diagram) Khasi loan dot nghit'p Trang 17Hg thOng tra cirti thiing tin tin xe Nguyen Holing Long A10805 ) -darainSicheduieliendier “Java Das» eActIvIlyTrain Schedule eamMtirareparlabmholcer <claws °saw.> etrainDertabasellaitffier condinalwatinkatripat osE)011AJAESSAGE: String VTAG: String erigriarainSchedule: GritNiew sorDATABASE_VERSON: in asspinnerTreinRoute: Spinner StEDATOtenspinsiE: sting esspinnecUrrer: Spinner trisilDatabaseHandiermontext) •creeteTableTrainSchectule(Stril,Sbing,Assetianager)voil •getDeperkureStatbn(StringeArreyLiskString>)ArrnyLisKStrinp •getiOTrain(Setig,ArreylinteSbinp):Arreytist<Strip •getTrainSchedule(Strin,String,LiskSbing>):List•Gbing> •creeleaffrainScheeule(Cantext,Stringg):voil •onUpgrade(SOLiteDetegastintintyvoid •onCreate(SOLleOetebese):void aserrIDTrains:ArrnyLitt<String• 0..1 nstotTrahSchedule: List•StrIng, oserrTableName: String efActivilyTreinScheduIe0 •onCreide(Bundlervoil •16201000SPnTuyenTeuo:voi0 •addiernOnSpnllasu(Boolenn):voin •onlemCick(AdapterVew<?>,VIew,Int,bnavoirl =Char stung Tuyin 641 UC #002 Tuyen buyt DOplitic tap: trung binh Mo ti Chile nang nay giiip ngieri &mg xem th8ng tin chi tiet cila met tuyen buyt, bao gem sic) hieu tuyen, ten tuyen, lief ke cac ben theo birth to chieu dive. Tic nhin Chinh Ngued &mg Phy 'Chong co Tien thin kien Khong co H§u lieu kien Think cling Hien thj danh sich bao gam ma tuyen va ten tuyin buyt Lai Thong bao loi vi gig nguyen giao dien Tuyen buyt DAC TA CHirC NANG Luang sw Mtn chinh/Kich bin chinh User case nay bat du khi nguai dung mutin xem thong tin chi tiet cac tuyen buyt co trong ca so du lieu (Ten tuyen, ma tuyen, cic ben chieu di/ve). 1.Nguai dung chan chirc nang Tuyen butt. 2.ling dung se hien thj danh sich cic tuyen buyt 3.Nguni dung chon met tuyen can xem thong tin. 4.Ling dung lay da lieu to Ca se/ de lieu sau d6, hien thj danh sach cac ban xe buyt theo trinh to chieu di dm tuyen. Khoa Juan dot nghiep Trang 18Ile thiing tra cut thong tin tau xe Nguygn Holing Long A10805 5.Ngueri dimg barn nut Chau di. 6.Ling dung lay do lieu tit Co so dO lieu sau de, hien thi dank sach cac ben xe butt theo trinh to chieu vE oh tuyen. Luling sy Men phit sinh/ Kjch bin phit sinh 1. Ngoai le khong ten tni Cu se do lieu Tuyiu butt 1.1. ung dung th8ng bao "Khong co co se' dO lieu Tuyen butt". Khan lu#n tot nghiep Trang 19Nguyen Holing Long A10805 Hg thong tra mit tilling tin Um 'Le Giao (Men minh hos 01 Ala* - Long gal . BF ite yfr UR xe Win Nil Bet - Ben -Yen Sti Nob I es xe Gia Um .._ Min Gil T6012 Bac Cli - Bet xe Y1614016 I Oulu di Tuyin 2 Bic Cd - Blin xe Yln –0 Chau ve 4n• 4 A% 1164 Cd '-‘...4 Ithinh cla Thin 1 — _ . Tdin Hung ect LOTS* _ <a Tring (Bii des xe Trio Du) Minh Dtr(dutetg 0e0 elz Birn xe Yen Nglib e 02 ZS Bic OS - e 03 glext Bel xe Gillp 04 Lone Bien <A QUECI. 6 cb, Be La 2 Wang Tiling (Hi Wing) Din Phil (He Deng)Nue* Tnii — Tang e os .C.A Khu 0 Ile Lire Dam-Phu ran — 06 Bin xit 016p Bit- Clu Su do trinh by (Sequence diagram) III,...01. chonTIwa) Yetiareadinieerdkino [ ,. ibi.i. xeuzauDerMachTtwenetel() n.1:1 t, .1 .., If, HenTleartiachtetenetell TraLaDartGadffereeleell xeucauDriSditienChleuDin OlorChleWen YeCefardSeSteraleuDY) • YeauDent6ad0enateuDin Tip) Ilia TheertexheenaleDif) teursueertfiacheereieueen IX Tel t HienfitkonliSecheenChleAke 1111.111111111111Th Su de lop chi flat (Class diagram) Khasi loan tot nghib Trang 20Nguyen Hoing Long A10805 He thOng tra cvu thing tin tau xe 411313usRoutethindler 0..1 ..... ............. «Jaws ans.> BusDatabaseHandler mm_ tanoanationsor Wave Gess>, e ActivilyDisplayDirections can.ntspespnternS eBusDetabessMandler(C00000) •createausTablalructureavoid ItrefroveltibteSpece(StriwyString if ActiviyDisplsythrections() onCreate(Bunde):void •populeteLVDirectbns(Kintint,Strig):void •getBusRouleNameorttStringyStrIng •onCreateOptionsMenu(Menu):booltan •onClick(View):void fhpltSlittion(String)Amryustcstrrp iisExerfisIChar(char):booieen Ihseree(AmlAkkgrilpArreyLIKS/rinip,int):vold eiremenreDuptatedStstonlArrsyLlskSbitp,t4):ArreytlebtSkinp •velTableElements(Conted):Elements •hsertriTableflautes(Contextyvoid •inerlInflablagations(Contecl):void •InserlitilibleSagments(Contextyroil •es1111304(Sting):String •geSen2ChingArrayLiskStrimp.Strilltttyvoid •gelBenCuoi(SIMM:Shing •insarteanGhlUnglkten(Slring,String,String)voil •getRoule_k1_14ane(LiskISIViewRouteRovn)vOid •geStabontlatne(int):Striv •geftouleNarre(rd)String •gelStstIonilanies(ArraylistcStrinp):voi0 •ge1100epArrRoute(ArrayLisIchteger0,):voill •onOpen(SOLI1eDetsbase):voil •onCreate(SOLleDatibase):void •eillipgrods(SOLteDstabsse,itint):void A <4.1ava Class>, e ActIvityBu sRoute anittormeninansper eAcbviyIkiaRoute() onCreateglundIeyvoid •onCreateOplionslienu(Ilenu):bookan •ontemeick(AdepterView<?>,View,Kbng)vold Cher ndng Chuyin tuyin UC #003 Chuyen tuyen DOphoic tap: cao M8 ti Chfrc nAng nay se h6 try ngutri dung tim ra met phucmg an chuyen tuyen xe buyt non nhe't giita ben du va ben cuoi do ngtrai dung nhap vao. Tic nhan Chinh Ngtrai dung Phy Khong c6 Tien diet' kien Thinh cong Kh6ng c6 Hien thi dank sach hutmg dan each chuyen tuyen ngAn that de di tir ben tau den ben cuoi Win dieu kien Lai Thong bio Itii va Oa nguyen giao dien Chuyen tuyen DAC TA CHIC NANG Lang sv kien chinh/Kich bin chinh User case nay bit du khi ngutri dung mu6n xem twang dan di chuyen tir ben du den ben cuoi sao cho so tuyen phai chuyen Itt it nhit. Khali loan tot nghiep Trang 21He thong tra ctiu thong tin tau lie Nguyen Holing Long A10805 1.No:6i dung awn chirc nang Chuyen tuyen. 2.ling dung se hien thi 2 o de ngtrei dung nhap vao ben tau, ben cu6i. 3.Ngutri dung nhap vao ben du, ben cu6i. 4.Ng dung hien till gqi 5, ten cac ben Ung yeti chu8i nguai dung [tap vao. 5.Ngueri dung chgn ten ben eau, Si mong mu6n. 6.Ngueri dung chgn nut Xem 7.Ng dung My gia tri ben datilcu6i nhap vim sir dung thuat Man Dijkstra ket hgp vEri Ca sg der lieu de dtra ra phuang an chuyen tuyen. 8.Hien till dank sach huang dan chuyen tuyen de di tir ben du den ben cuSi. Luling sv ki'n ph& sinh/ Kjch bin phit sinh 1.Ngoai 1 khang tan tai Ca s& dit lieu Tuyin butt 1.1. Ding dung th6ng bao "Khong cO co so da Ru Tuy6n butt". 2.Ngoai le khang tan tai phuung in chuyin Owen 2.1. Ding dung thong bao "Khong cif) phuong an chuyen tuyen". Giao diet' minh boa .--, HC 1T ga0 lHD' ' An Dito'ng Vining 'Ong Wen Nglifa D6 lal Vutnig Mo len Unh 46 T:nben An Wang Tityt 31 Ma lama - DONE Mtn) Xiang ben Au Ca rel 1PPTuyen Sinn Phu- mit Me So 4 trinh tir (Sequence diagram) Khoa lu(in dot nghiep Trang 22ALlivityFrndi ransit DiO Graph CharThuatToanTrenottleun vit.FI rffiTran sit DAO Database Graph He timing tra aim thong tin tau xe Nguyen Holing Long A10805 Khoa lien vat nghiep Trang 234.4sva caw> ellasDatabaseliandier cowu_varspaamospot teusOststmsthandler(Conter0 •ereateBusTableStructure0:vod iresoveWhieSpac•String).Strag 4i0010000000(50001)ArrWUskgatip eiatc•IFIrstCharteksaboolea 1001000130,(AnnaKS0r•PArreytAt<Strhp•tYwid tholrovorOupleatedStab*ArrmatcSbInp,MAm•LatcStrip •wiTableflomults(Cord•l):Etnents •inserthillbleRoutn(C0000):0.• •Insethfrobl•Staltat(C.1000)v001 •InuretiTateSerneat•Contex0.wel •pletl•(St009):Stro9 •0010•02Cluou(AnyLSSIrnp.Strinsial):wod •geSsaC001(00009) Slam •EmereanCIA•sngban(Stril•00100.5000):v010 •getRouls_10_Name0atcLaMerlouteRowoyvorl •getStationNawe(nt).Shing •gegoulatismet)Strin ••06100onttames(Arroylat<Strinp):voed •geleDs•ArrROutnrrnti•41090r0:thold •0001miSallsOstatesstvoid •ontastsrateDslabste)xOd •onUpywWSCILIalleabase,nlintrveil <40v1 CAsts” eActIvityRodTranit tc.511.VOSPOnntahOle 01Adw•FlnatanstO 0 onCrestelBundleyvotl •onCree43pl6nalienu(Ilenu):boo4sn •getStrk•Onaub•n0Strin •SkOWA•raibliOVIS a-Ina caw, ODasktra can.atmospanessper groans° onPostExecuteModIvo• .> doinseckstoundtwilOwoc 0 on Preencuteavokl <4.1sva Chun pillar' terelitiMRSPNOMMIISIpat St. ....... •sallsInPriorty(Rbeifisanyvaid •ge0sInPnorly0aboten Dfugra(Grap0) •selArrirraceList(ArrsylikArrayLid4TroceLstnrvoba •geAntfreceLlst()ArrayUWArntyustarsortio> •1000):vod •PrintStatusOlPriorits20:void •pinfrracelistavokl •00dTtsceLlstO:vold •seffraceStatbnait0v011 •prhIS•ckTractRouttO:vold •maraces00100(00.AnflarscaLSM:Stact<Tracellst• •getStackTracallotdeCount(Steck<Tracellsbyinl •getilickTracaRoula(StadoefracatirEqvul •getFilaRoute(Stactaracells•ArrsyLE0•00.):votl •gatFinalTransiStatirsintAnylJulcida•)Y001 O beepCopyArrayList(AtinistarectrUsb)ArraytiWTracelisto •deepCopyTraceLid(ArrayliskTraceLlsh)ArraytitaraceLlst. •sOltracelistTargead):ved 44.11V1 WOW' el TraCeuSt torkkinreporiamthaim -Tnactrist tractiAlentercrepechteger) IFTranUsterractist) •salCurremlnodeontregeryvoid •getCurrentliodgyIntager •setPrevIlode0M•pertved •getPrevNodeallittg• •settlioutt0,001000:v0a0 •gettlRoutealrair 0 • 0• -stadffracaftouta Nguyen Holing Long A10805 Hg thOng tra cvu thong tin du lie Soli d6 lop chi fiat (Class diagram) Chet non Dinh vi UC #004 Dinh vi Dlphirc top: trung binh M8 to Chic nAng nay cho biet vi tri Men toi dm nguiri dung tren ban di) s6 (Google Map) vi dia chi dm vi tri do. Tfic nhfin Chinh Ngutri dung Phy !thong co Tien Wen kiln Killing co Khios lutin tot nghiep Trang 24Nguyen Hoing Long A10805 Hg thting tra caru thong tin titu xe A Han dieu kiln Thinh cong Hien thi danh dau vi tri ngutri thing tren ban 6 s6 (Google Map) vi dia chi dm vi tri do. loli Thong bao len. DAC TA alit NANG —A Luong str kiln chinhfKich bin cbinh User case nay bat du khi ngubi ding mutn biet dig chi caa vi tri hien tgi va no nam a dau tren ban d6 s6 (Google Map). 1.Ngueri thing chon chit nang Dinh vj. 2.Ong dung Ur dOng lAy da lieu vi tri hien tai thong qua chic nang GPS sau do, gin you cAu yE du lieu ban 6 cho vi tri nay dEn Google server. 3.Ling dung nhan du lieu ban 6 tra ve tir Google server riii hien thi danh dau va thong tin cna vi tri tren ban di 4.Ng dung hien Uri gqi 9 ten cac ben (mg vii chuSi ngutri dung nhap vao. 5.Khi ngu&i ding di chuyen, img dung lap Ili cac bulk 3, 4. Luting sy kiln phit sinh/ Kjch bin phit sinh 1.Ngotti le chin bet chat Sing GPS 1.1. iTng dung th8ng bao "Ban co mu6n bat GPS?". 1.2. Ngu&i dung chon "Co". 1.3. Chuyen den muc bat chirc riling GPS calf thiet bi. 2.Ngooi lekhong tim dully dia chi cim vj tri hien tai 2.1. Ling dung hi& thi vi tri hien tai nhung Ichong kern thong tin dia chi. Khan luOn tot nghiep Trang 25Nguyen Hoing Long A10805 Hg thiing tra miu thong tin tau xe Giao ditn minh hQa •2 Ho tr, Inn, .< RPOUSI 0 • /0" rtn mg M5- IMP Trans Ian. HI N41. • V,, oirat or til 7„1" la ag Mai Ni a VIM Quill Pala NY , N.A. So da trinh ty (Sequence diagram) User User ActivityGmapPosition chonchucNanaNnOVIO GPS Googl YeuCauToaDoHlenTal() Server HlenThiDuLleuBanDo() ActivityGmapPosition TraLaiToaDoHlenTal() 111 YeuCauDuLleuBanDoChoVITHHIenTai() TralalDuLleuBanDoChoVITHHIenTal() • GoogleServer GPS ) • Su d$ lop chi wet (Class diagram) IChea lulin tot nghiep Trang 26Nguyen Hoing Long A10805 He timing tra cut thing tin tau lee .tuava Clans, (2/ ActvityGraapPositioa tom kleesseortieboodoer o googleilap: Googlellap a finalResalt Shin mFleceType: WOO nflaceTypeName: Stine Matlack: double 44.18vil Claws liainActivity a nem geode: double matatamiamamaaaar A currentLocation: Location afuannctrveyp efactinlyGaraPosiban() antreata(Bundle)vad anCreate(BuitOnma• •onCresteOptionalleau(Menu):boolean •anCradeOptionsMenu(Lienu):boolean n itliehvodavallableabaaban •orescatbeebenged(tocabon):vold n downbadUrKSIrhoySting •onProviderDisabled(String):voil •anProvilerEnabied(String):vaid •onStabssChanged(String.KBunde):voil •ofillapCfck(Latng)waia Char fang Bin xe 641 UC #005 Ben xe buyt Dtlphirc tap: cao Mo ti Chic nang nay se danh dau vi tri cac ben xe butt glen veri vi tri hien tai coa ngueri dung kem then dia chi dm cac ben do tren ban del siS (Google Map). Tic nhin Chinh Ngu&i dung Phu 'thong co Tan (lieu Men Khong co Hiu dieu kien ThInh cong Hien thi danh dau cac ben xe butt glen yeti vi tri hien tai dm ngueri dUng ten ban do so (Google Map) va dia chi cila cac ben do. Lai Thong bao 16i. DAC TA CHI5C NANG Luang sy kiln chinh/Kich bin chinh User case nay bat tau khi nguai dung main tim cac ben xe buyt quanh vi tri hien tai. 1.Ngueri dung chon niitBen xe butt trong chile nang Dinh vi. 2.Ung dung hr di:mg lay du lieu vi tri hien tai th8ng qua elide nang GPS sau Khea hien tot nghiep Trang 27Nguy& Hoang Long A10805 He thOng tra ciru thong tin tau xe do, giri you cAu ye du lieu ban do, thong tin ye cac ben xe butt gan vi tri nay den Google server. 3.Ng dung nhan du lieu tra ire tir Google server rAi hien thi &Mt dau va thong tin dm cac ben xe butt gait vi tri hien tai ten ban do. LuOng sw Men phat sinh/ Kjch bin plait sinh 1.Ngoai le chin bet chic nAng GPS 1.1. ling dung th8ng bdo "Ban co muAn bat GPS?". 1.2. Ngtraci clang awn "Ca". 1.3. Chuyen den mac bat chic !tang GPS can thiet bi. 2.Ngoai lekhong tim dirge dja chi dm vi tri hien tai 2.1. fling dung hien thi vi tri hien tai nhung Bong kern thong tin dia chi. Khoa hien tot nghiep Trang 28Hg thOng tra cdru thong tin tau xe Nguyen Holing Long A10805 Giao dien minh hoa HntrItia)thl + vr Ws*" 0 49.14 Yin mei ... M VI 66S - IV Trion Vin. WI PRA. VillirWI km elms ma ng Pa 4 GS ils Von 1 natl. + VA u 0. Sift Su dO trinh tv (Sequence diagram) User User ActivityGmapPosition ChonChucNanqDlnhVIO,_ GPS YeuCauToaDoHlenTalo .. GOOQ I eS er v er ver IP ChonBenXeBuyt() .. IP HienTh1DuLleuBanDo0 ActivityGmapPosition • , TraLalToaDolifenTalo • YeuCauDulJeuBanDo/XeBirstChoV1TrIHIenTal().. TraLalDulJeuBanDo/XeBuytChoVITHHIenTalo • Goog leSer GPS So da lop chi wet (Class diagram) A Kb& luOn tot nghiep Trang 29Hg thong tra aim thong tin tau re Nguyen Holing Long A10805 «Java Caw. BusDatabaseliandler ova Pluartspastatenkets «Java Claw> ActivityDisplayDirections cant M.tartspartalothelper iflusDelabesellander(Contaxt) •ereatellusTableStruclureavoi0 eremoveVatteSpace(String):51rin AcliviyDispleyDirections() onCreate(Bundle):voil sollStaban(String 1Anry(iskStritp •populateLVDirediongint,inkint,Sbilgyvoil •getButRouteldemsOnt,StriwyStrhg •onCreateOplionafmuNenuybooesen 4101:1aFtoutellandler OS isExislErstChar(clar):00okan iflerten(Arrritkt<StrinpArrayLibtStrinfp,Int)voto dreirovsOuplcateatation(Arraytildtrinp.Int)ArrayLIE<Stenp •esITSYMenierds(Conted):Elemenbt •onack(Visw): Ito d 0..1 •InsellniTs100Routes(Cantext)roid •imactin110010Stalions(Coderlyvoil •inserlkesbleSegmants(Csataxt)void J <0J an Classy, e ActivilyBusRonte yo.m. unparumonhaper •0,11:10.1(Steng):Stritg •gelBe0200eu(Arrayliskgriip.Strin 0, int)void •gallkiCuoi(Strin):Sbin JActivtyButFtoute() onCreate(BuncHe):vad •ilser1BanGhtlangDoan(String,String,String)voil •gelRoultItNarrta(LisktitNiswliauteliaw>):vkl •onCreste0 ptimsAl gnu (LI enu): boolean •0dStaIlonnerns(ind): Stilt! •ntemC lick(AdapterView<?>,View, int 10 n g)voil •gdRoutellame(idyStritg •0003tronnarnsm(AftlYtIst<S100P):vail •geODISArrRoute(ArrayLisIddeget):void •anOpen(SCILleDetsbase)vokl •onCrode(SCILleDstabase)void •000P9r1100(SQUIeDglabese,Intiit1: void Khea lukin eat nghib Trang 30Hg thong tra ctiu thong tin tau xe Nguyen Hoilng Long A10805 CHVONG 3. THE& Ke VA TRIEN KHAI Nhu da phan tich 6 cac chtrcmg truec viec Ilya chqn phat trien ung dung chay tren he dieu hanh Android dat duqc nhieu tru the ham so Nit% cac nen tang khac, rddim tim hi'eu chi tiet han ve cac uu the nay, chi:mg nay se phan tich sa lucre ve kien true dm he dieu hanh Android vi kien true thanh phAn cua img dung. 3.1. He dieu hinb Android thieu: Android la hg dieu hanh dinh cho cac thiet bi di &Ong dtra tren nen tang Linux.Ban Mu, Android duqc phat trien b6i Android , Inc. Nam 2005 Google mua lai ding ty nay. Google cang cac dei tic gOm nhftng nha mang vien thong, cac hang sin xuAt this& bi di &Ong da cimg sang lap Open Handset Alliance (tam dich: "Lien minh Thiet bi cam tay Ma") va phat trien Android. Thing 11-2007, Google chinh thirc gibi thieu phien ban Mu tien den vai thi truong dien thoai di ding thong minh. Lich sir phat trien dm Android dirge tern tit trong bang sau: i.0 23 thing Chin 2008 L1 9 thing Hai 2009 1.5 30 thing Tu 2009 1.6 15 thing Chin 2009 2.0/2.1 26 thing IvArtri 2009 2.2 20 thing Nam 2010 2.3 6 thang Mu& hai 2010 3.0 22 thangHai2011 4.0.1 19 thing Ivitriti 2011 4.1 27 thing 8Itu 2012 Bang 3.1. Ltrqc sir phat trien he dieu hanh Android Ithea luau tot nghib Trang 31(Location-Based) Content Window Services Providers J l Manager Package Manager ) Activity Manager P2P/1M (Notifications) Resource Manager Telephony I N ( Graphics (OpenGL, SGL, FreeType) 3 Hg thOng tra cum thiing tin tau xe Nguyen Hoing Long A10805, Android 1.0 va 1.1 khong duqc dat ten ma. Phien ban 1.5 co ten Cupcake va theo do, moi phien ban dEu mang mO't ten pi thuong" di kern, nhu Android 2.1 Eclair hay 2.2 Froyo, 2.3 Gingerbread ... =Kiln Ink he eau hank Android: Cac thanh phan ca ban dm Android duqc mo to 6 hinh sau: Application Layer Native Apps Contatts, Maps. Browser. me)) Third Party Apps 3 1 L. Developer Apps Application Framework Libraries Linux Kernel Android Runtime Android Libraries (Dalvik Virtual Machine Hardware Drivers Power Process Memory (USB. Display. Bluelooth. etc.) Management Management Management Hinh 3.1. Kiln triac he dieu hanh Android + Linux kernel — cac dlch va ca ban dtrqc diEu khiEn 136i nhan Linux 2.6 (trinh diEu khitn phan cimg, quan 1S, tien trinh va b0 nhe, quan 1Y an ninh, quan 1S, mang va ngutin dien). + Libraries — cac thu vien C/C++ co ban nhu libc vA SSL, ben canh do la: —Thu vien cho xir 1S, nhac va video —Tharth phial hd trq hien thi Khoa luCin tot nghiep Trang 32Hg thOng tra cvu thong tin tau xe Nguyen Holing Long A10805 —Cac thu vien SGL vi OpenGL cho dfi hoa 2D va 3D —SQLite cho Ca se de lieu —SSL va WebKit cho trinh duyet web tich hqp va an ninh mpg +Android runtime — gem cac thu vien ca ban gift!, trinh cho Android bang ngon nge Java vi may a° Dalvik, giep trinh vien choy the cac 1mg dung. +Application Framework — cung cep cac 16p de" to nen cite 1mg dung Android. +Application Layer — cac (mg dung se hoot deng a 16p nay sir dung cac lop va dich vu dugc WI fro 6 tang application framework. 3.2. Chu trinh song cfia met irng dyng _Activity la gi? Met Activity IA met thanh phan cea img dung Wang to' nhu met man hinh cho phip ngutri deng thoc hien met you eau nio do, nhu goi dien, chop kill, gei email, hay xem ban de... Met eng dung thuang bao gem nhieu activity duqc lien ket veri nhau.Khi 1mg dung dugc khoi deng, met activity c6 the goi den cac activity khac de thoc hien nhieu Wirth deng khac nhau.Moi khi activity mai dugc goi thi activity tar& do 0 dung lai, nhung he thong van Wu no loi trong met ngan xep gni la "back stack". Khi met activity mai khoi clang n6 cling duqc dua vao back stack. Ciu irk nay co ca the hoot clang gieng nhu ngan xep, "vao sau, ra trutc". Theo de, khi ngueri dung lam viec xong vai activity hi'n tai vi him net Back, ne se hi day khei ngan xep (ding thai b1 hey) vi cac activity tnrac no se dugc khoi phut loi. Chu trinh sang coo n10 activity (Activity lifecyle) Chu& cac "hank deng" met activity se thoc hien tir lec no duqc bat dau den khi ket thee duqc goi la chu trinh song. MOt activity dugc kWh deng, no se dugc dat o dau ngan xep vi tra thanh activity dang choy (running activity), activity tru6c no se nam phis duOi trong ngan xep, va se khong dugc goi met khi activity tren no van con ten tai. Met activity se c6 ben tong thai sau: +Neu met activity hien dang hoot deng (6 dsu ngan xep), no duqc goi la dang hoot deng hoac clang choy (active hay running). +Neu met activity ;thong the Wang tic dugc nhung An hien, n6 duqc chuyen v'e twig thai tom &mg (pause),nhung trong tnreng hqp be nhe can kiet, he thong se ket thec activity nay. Kh6a lufin tot nghib Trang 33Apps with higher priority need memory He thOng tra cult thOng tin tau xe Nguyen Hoing Long A10805 +Neu mOt activity bj the hoan toan btri mOt activity khac, no chuyen ve tang thai ding (stop). Lim nay no co the bj ket thac ba he th6ng n'eu co mOt img dung nao do can b0 nh6. +Neu mOt activity a trang thai ding ho4c Liam ding, hg thong se hal ho4c tu dOng ket thac den trinh ma activity nay nim giu de x6a no khei be nhtr. Khi hien thi lai cho nguOi dung thi activity nay duct khoi dOng va khoi phuclai tang thai cua no tnrac. So a dm% day mo to chu trinh s6ng cua mOt activity: Use navigates to the activity big:mate° weed° 4 onFlesumeg 4 ooRestartei Another activity comes into the foreground use returns to the activity onPauseg The act!vity is no longer visible 4 onsiopo The activity is finishing or being destroyed by the system onDestroy0 User navigates to the activity Hinh 3.2. Chu trinh s6ng cna mOt Activity Cac phuang thirc duqc goi trong chu trinh sting dm met activity: +onCreate 0 Kluia luen tot nghlep Trang 34He thOng tra cum thong tin tau xe Nguyen Hoing Long A10805 Dirge ggi khi activity dugc khoi lito.Cac thanh phin giao dien va khoi Mo du lie'u dugc thirc hien a day.Phlicmg thac nay cling di kern veri met &Si ttrgng Iuu lit tang thii trade do ctia activity. +onRestart 0 Dugc ggi sau khi activity dimg. +onStart 0 Dugc ggi khi activity hien thi veri voi ngueri dung. +onResume 0 Dugc ggi khi activity bat dku tuong tac veci ngubi dung. +onPause () Dugc ggi khi hg tiding muon kh8i phlic Wong thai dm activity truck do.Phucmg thirc nay thu&ng dung de luu lai du li'eu, hay dimg bit cir hoat ding nio tieu ten CPU. +onStop 0 Dirge ggi khi activity kh8ng con they dugc, vi met activity khic de dugc khoi phlic va the phit len activity nay. +onDestroy 0 Dugc ggi khi kat thew activity hay hg thong tom then hay no de lay khong gian be nher. 3.3. Jaen trtic m3ng Chtic nang "Dinh vi" cua Cmg dling co ket nti veri mpg Internet de lay th8ng tin, hinh clued day mo to each tinh neng nay lam vi'ec vai mang: IChea 1u4n hit nghiep Trang 35GPS I., Wifi hotspot Hg thOng tra cvu thong tin tau an Nguyen Hoitng Long A10805 Google server /11 tjk Android phone Tram 111'S Internet Hinh 3.3. Kien true mang Dien thoai th6ng qua chnc nang kat n6i GPS (Global Positioning System) se lay thong tin ve tna dO cua vj tri hien tai g6m co longitude (kinh dO)va latitude (vi d0). Sau 6 din thoai se ket not v6i mang Internet thong qua Wifi hotspot hoc tram viIn thong (BTS) rai gui dfr lieu tai Google server, thong tin tra ve la cac Map Fragment chfra dfr lieu hinh anh ve vi tri hien tai tren ban d6 Google map. 3.4. MO hinh boa de lieu =So di co* so de lieu Tuyen Dor Ilea Colas Name Coesnord TeX SYS cam. sae Cada Nubble 3:1=1100 Oars POS Oninad Type SASS q Muss wt ND eSssce T Ottesean 19 Dien m Ne TenTuven -1 ND Dleenet re Ib Tween tea Cinau 1st Tea reenses at Teresa — M 0001 at wt NI la Ts To Sae tort Yes Hinh 3.4. Sa d6 co so du lieu Kluia 1011 tot nghiep Trang 36He thong tra eat thong tin tau xe Nguyen Holing Long A10805 trac Sc bang dr? lifu Bang Tuyen 1. S6 hieu: 1 2. Ten bang: Tuyen 3. Bi danh 4.Mo ta: Luu thong tin dm cac tuyen bu't 5.Mo ta chi titt the cOt S6 thin W. Ten cOt M6 ta Kieu du lieu Null 1 IDTuyen Tnremg kh6a INTEGER NOT NULL 2 TenTuyen Ten dm tuyen TEXT NOT NULL 3 GhiChu Ghi chit cho m8i tuyen TEXT ALLOW NULL Bang 3. 2. Bang dit lieu tuyen xe bukt Bang Doan 1. se hieu: 2 2. Ten bang: Doan 3. Bi danh 4.M6 GI: Luu thong tin ye cac doan cua mOt tuyen 5.M6 ta chi tiet cac cOt S6 thir to Ten cOt Mo ta Kieu du lieu Null 1 IDTuyenDoan Trtrang kh6a INTEGER NOT NULL 2 IDBenTruoc 'Chem dm bang Ben INTEGER NOT NULL 3 IDBenSau Khea dm bang Ben INTEGER NOT NULL 4 Chieu Chi dinh chieu di hoc ve BOOL NOT NULL 5 TrongSo Khoang each gift 2 ben INTEGER ALLOW NULL 6 GhiChu Ghi chit cho miii doan TEXT ALLOW NULL Bang 3.3. Bang dfr lieu cac doan cua tuyen xe buYt Bang Ben 1. S6 hieu: 3 2. Ten bang: Ben 3. Bi danh 4. Mo ta: Luu thong tin dm the ben Kluia luen tot nghiep Trang 37Nguyen Holing Long A10805 Hg thong tra criu timing tin tau lie 5. MO to chi tiet cac cOt SO thir to Ten cOt Mo ti Kieu dor lieu Null 1 IDBen Trtrang kh6a INTEGER NOT NULL 2 TenBen Ten cfla ben TEXT NOT NULL 3 GhiChu Ghi chit cho miii ben TEXT NOT NULL Bang 3.4. Bang dd lieu tic ben xe butt 3.5. Trien khai DE xay dung ducfc mOt frng dvng Android thi Mr& het to phai hieu ve eau tree ctia mOt project Android, cach no sip iep vi quan It file thE nao. Mpt (mg dung gom nhang phan gi va n6 hoat dOng ra sao va each (mg dung xay dung de' tai. Chtrcmg nay se trinh bay kha chi tiet cac nOi dung ke tren. Khoa loan vat nghiep Trang 38Hg &Ong tra ciru thong tin tau lie Nguyen Holing Long A10805, Cau frac coia miSt project Android Cac thanh phan co ban cim mot project Android bao gam: •src — china file ma ngu6n co duoi *.java. 6 vi du nay chi co 1 file la, MainActivity.java. MainActivity.java la file ma nguen cho activity nay. •Android 2.3.3 — thimh phan nay chi chira 1 file, android jar, bao gam cac tint vien can thiet cho mot img dung. •gen — chin file R.java, file nay duqc trinh bien dich tg dOng sinh ra, chi ra lien keit den cac tai nguyen co trong project (hinh anh, cac chuai, nth barn...) Khong nen thay dei file nay. •assets — chin cac tai nguyen ma img dung can de hog dOng, nhu file HTML, file van bin, co so du •res -china cac tai nguyen ben ngoiii nhu: hinh anh, cac file dft img dung Android sir dung. AndroidManifest.xml -chin thong tin ye cac activity, view, dich vv... No cling liet ke ra cac quyen can thief de mot img dung Android hog dOng. au frac cue file AndroidManifest.xml Package Explorer n 8 % •Tzg HelloWorld •I src •9 com.aample.helloworld M MainActivity.java •2: gm (Generated Java Files) •al com.aample.helloworld BuildConfig.java Rjava •als Android 233 •android jar - C: 1kers.tkindcwsT.e o M Android Dependencies u3. assets bin •libs •to res •Ea drawable-hdpi ic_action_search.png 1:11 ic_launcherpng •drawable-Idpi; drawable-mdpi drawable-xhdpi •ey layout a activity_mainarn1 •t2x menu •values stringsaml 61 stylesatml AndroidManifestarn1 ic_launcher-web.png •proguard-projeatct •projeaproperties 113 MyFirstApp 4 I Hinh 3. 5. Ciu true mot project Android <manifesaunins:android="http://schemas.android.com/apkires/android" package="com.example.helloworld" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" Kit& 1u4n tat nghi4p Trang 39H? thOng tra ctiu thilng tin du le Nguyen Holing Long A10805 android:targetSdkVersion="15" /> <application androidicon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/title_activity_mdm" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" I> <intent-filter> <activity> <application> <manifest> File AndroidManifest.xml chira thong tin chi tiet ye Ung dung: •Chi ra ten package elm Ung dung, 6 vi du nay 11"com.example.helloworld" •android:versionCode: chi ra phien ban cea (mg dung. Gia tri nay can thiet khi nang cap (mg dung. •android:versionName: gia tri 6 deng nay se dung de hien thi phien ban cho nguai citing. •android:minSdkVersion: chi ra phien ban nhe nhat ma Ung dung se hoat ding tren do. •android:targetSdkVersion: chi ra phien bitn cao filth ma img dung co the hoat ding ten do. •android:icon: img dung se sir dung ic_launcher.png nam trong dm flux drawable. •android:label: ten coa ung dung li gia tri app_name duqc dinh nghia trong file strings.xml. •Chi co met activity dai din bei file MainActivity.java. •Phan tir<intent-filter>: dang ki ck activity, dich vu va Broadcast Receiver de thao tac tren be dci Ru. Khan lui:in tilt nghiep Trang 40He thiing tra cum thong tin tau re Nguyen Holing Long A10805 R.java NOi dung dai din cfia mOt file Rjava: package com.example.helloworld; public final class R public static final class attr { } public static final class drawable { public static final int ic_action_search=0x7f020000; public static final int ic_launcher=0x7f020001; } public static final class id { public static final int menu_settings=0x7f070000; } public static final class layout { public static final int activity_main=0x7f030000; } public static final class menu { public static final int activity_main=0x7f1360000; } public static final class string { public static final int app_name=0x7f040000; public static final int hello_world=0x7f040001; public static final int menu_settings=0x7f040002; public static final int title_activity_main=0x7f040003; public static final class style { public static final int AppTheme=0x7fD50000; } } File R.java ducrc trinh bien djch to dOng sink ra, file nay duqc sir dung de quan ly cac thoec tinh duqc khai bao trong file XML ctia ling dung. Ma nguen cart file Itjava dugc ttr den sinh khi ce bit ki met su kien nao xay xa lam thay d'ei cac thu(c firth trong img dung. Vi du nhtr, them file hinh ant dr ben ngoai vao project thi dtrong dan den file Kit& lu(in tot nghiep Trang 41He thong tra cam thong tin tau xe Nguyen Holing Long A10805 d6 ciing co trong file Ittjava hoac xoa mot file hinh anh thi dutyng clan won Ung dEn hinh anh do cling to dOng bj xoa. 3.6. Xii ly dir lieu dAu vlo DE c6 duqc thong tin phoc vu cho viec lay dung co set du lieu mot each chinh xfic va to dOng, thi truErc het, thong tin dau vao an phai dtrqc xi: IY de loai b6 cac yin t6 du thira dOng th6i phai duqc t6 chic sao cho viec lay der lieu dat duqc bleu qua cao shat. _xi( Ifi Hang tin gio tau Vi do. lieu tai dia chi http://www.vr.com.vn/gio-tau.html duqc bao ye bang SSL (Secure Socket Layer) nen khong the ray ve to dOng do do cac trang th8ng tin nay deu phai luu lai thu along de sir d(mg 6 clang offline. Tire IA co 10 tuyen bao "HA NOi - Sai Gon" "Sai Gen - HA NOi" "HA NOi - Lao Cai" "Lao Cai - Ha NOi" "HA NOi - Hai PhOng" "Hai Pheng - Hi NOi" "HA NOi - DOng DAng" "Deing Dan - HA NOi" "HA NOi - Quin Trieu" "Quan Trieu - HA NOi" se co ttrong Ung 10 file HTML "gt_Hanoi_Saigon.html" "gt_Saigon_Hanoi.html" "gt_Hanoi_Laocai.html" "gt_Laocai_Hanoi.html" "gt_Hanoi_Haiphong.html" "gt_Haiphong_Hanoi.html" "gt_ Hanoi _Dongdang.html" "gt_Dongdang_Hanoi.html" "gt_Hanoi_Quantrieu.html" Khali lutin tot nghiep Trang 42He thing tra colt thing tin tau 'Le Nguyen HoIng Long A10805 "gt_Quantrieu_Hanoi.html" Turin Ski GOn - Ha NOI n MI au - TOO - - Ga di Sii Gem n Gs dial Hi NOi mot. 4.1inGTAV SF2 SE4 SEA SFS SE10 SE12 SE14 SEM 131 Sii Goa 19.00 23.00 15.45 6.25 22.10 13.25 835 10.55 14.0 BAN 116. 19.39 - 19.42 16.24 - 16,27 7.04 - 7.07 Load !alai al.- .e.../...._ It fial •tt It IF *Hs Hys_mil z as Sall. Dos tut combs I P Et I thirth Wa I hittrowes < liteabir ulhd • tiablock tbarraiwal c CfrIabler • eaparaidle • bo* ecltv 1sle•.wer• el•Ssenecar>. •.& <table ideffit, clemee•tf.l_seettlif tridttnelfC1• cellsgaclar”. allOadding••3. nae."'•11' eft:car' et.x . vallgoefaildlef> etb, eldr.lfeflf O. acme. eci•sIbt a MAC' TAIref thy •zlt scapenfeel'elill•tfb• •ch vegpe•• nal'. 114 tithe •fif scopreecelff.5164/zin. etb earpee•colfaltil t/t/ta er.la scogwe'ctlf.111101, thy <u•capas'eol'ailiz.t/th. <m•ectee, eel. .1214 (ital./ 4t.ft •ftneee.efl fill •/the <cif ecope.,Cfl'f.SMIe/the .ttla •copeeettlf1.1114e/the eth •eaptefeelf1.21111.titin 4ch seapir,cal..:111.24/t.bl. 4th •copee-telf).7511.cita, efts> raffray.. <Sof stvlenftest-•11eaf left. featnrelelit bolt f•f a.t Gartefule Hinh 3.6. Minh hoa eau true file dau vac, Cac file HTML nay se duce luu tai muc "assets" caa project de phuc vo cho viec lay der lieu. Sau de ta se sir ding mOt thu vien Java ten la "Jsoup" de doe cac file HTML theo cau true DOM nharn tim ra the chfra dfk lieu mong muon. Vi do, ta muon lay ra tip hop cac dong dm bang trong hinh minh hoa tren c6 the dung doan code sau: Document doc = Jsoup.parse (outStream.toString ()); Element tblContent = doc.getElementByld ("grv"); Elements tblRows = tblContent.getElementsByTag ("tr"); Vai Document, Element, Elements la cac doi tuqng ducrc dinh nghia trong thu vien Jsoup, outStream la file HTML &roc doe vao thanh lung de lieu.Sau khi thy throe dU lieu can thiet thi viec tiep theo la tao cu sir du lieu va insert di lieu nay vao cac trtremg. De thuc hien cac viec nay lap TrainDatabaseHandler cung cap 2 phuong thtic createDBTrainSchedule (Context c, String[] arrTableName) de tao co sir dB. lieu vacreateTableTrainSchedule (String tbName,String link, AssetManager am) c6 dau van (An luvt la: —tbName — ten bang can tao —link — ten file HTML tai thu moc assets —am — doi tuqng quin 15, assets, cho ket qua 11 mOt bang da Toin b0 qua trinh tren dtrqc mo ta bang hinh sau: Khali 1u4n tot nghiep Trang 43He thOng tra ciru tilting tin tau xe Nguyen Hoing Long A10805 Mr lieu web Trang HTML Lisrde lieu va of nine --a WocasbdOr / Cu sir art lieu V Hinh 3.7. Quy trinh xir ly thong tin gib tau —Ham createDBTrainSchedule(Context c, String[] arrTableName): Nhu hinh 3.6, du ii4u ma to can la ma tau, chinh la cac chuOi SE2, SE4...nim trong the "th". Ham nay se !Ay ra cac chu8i sau do kit hqp di tao ra mOt eau lenh tao bang theo dung cu phap SQLite rot thuc thi cau lenh nay. Sau khi cau frac bang du lieu cua mOt tuyen duqc tae ra nhu tren, ham nay tiip tvc lAy cac chu8i tiip theo nA► trong the "td" bao gem ten ga tau, gib tau xuativao bin. Cu6i cling no kit hqp cac chuSi lAy duqc reg thtrc thi cau lenh insert du lieu vao bang. —Ham createTableTrainSchedule (String tbName,String link, AssetManager am): Ham nay se duqc goi trong activity ActivityTrainSchedule de tao ra toan bo ca so dr: lieu gib tau.Khi float dOng, no se gal toi ham createDBTrainSchedule not teen di tao ra bang du lieu ting yid m8i tuy'in.Hai thong tin quan trong can cho ham nay la: +am: mOt doi tuqng AssetManager quan IS' tai nguyen ma chuang trinh an sir dung. +link: dtrtmg dan din file html luu tai thu mix "assets" do AssetManager quan Dii tuqng AssetManager can cu theo duang dan duqc chi ra 6 tham so "link" se tim din dung file html co ten tucmg img di h8 thycho ham thao the ten cac file nay. MY It ly thong tin lupin 644 BuOc dau viec lay th6ng tin xe buyt cling duqc thut hien ttrcmg qr. nhu phAn truirc, tirc la trang web duqc luu tilt offline va luu tai thu !nue "assets" dm project. So v6i du lieu gib tau gi6 tau thi viec lAy dOr lieu ve tuyen buyt gap nhiiu khe khan ham. ICH, khan chinh o day la de lieu c6 clinh clang khong thong nhat va duqc mo to 6 clued day: Khasi lua'n tot nghiep Trang 44Hg thOng tra ctiru thong tin du ze Nguyen Holing Long A10805. 1.Vi ta can lay ra ten ben duy nhat de km vao ea set du lieu, nen cac ben giong nhau nhung co kern thong tin phia sau se ire( thitnh "nhigu", tat la chting se duce coi la cac ben {chic nhau trong khi do van chi Ili mOt ben. Vi do: ngoai ben Long Bien con co Long Bien (Yen Phu - Khoang 2), Long Bien (Yen Phu - Khoang 1). Ta chi can lay churn "Long Bien" de' chi ten ben, nhung nhungehuEi con lai ming chi ben Long Bien nhftng se ter thanh cac ben khac nhau neu chang dtrgc km vao ca set du lieu. Han nOra, ta dung dau "-" (gach ngang) de xac dish ki to phial tacit gigra cac chuili nen khi tach ra vi do yeti chutii "Long Bien (Yen Phu - Khoang 2)", ta se dirge 2 chu8i "Long Bien (Yen Phil" va " Khoang 2)". Hai chuEi nay tit thanh nhiEu. 2.Tucmg to nhu vay, chuiii "Quay du ding trey thanh nhiecu vi chuEi nay nam gida hai dau "-" (gach ngang), ki hieu de nhon dien va tach chuoi. Vi do: ra Dan - Quay dau tai don dien nge Xa Dan 2 - XA Din - Kham Thien Khi tach churl, ta se dung dau "-" (gach ngang) de nhan hitt ki to phan cach chu8i. Neu khong loai b6 chu8i "Quay du thiket qua sau khi tach chuEi se 11, XA Dan, Quay dau tai dei dien nge Xa Dan 2, Xa Dan, Khalil Thien. KM de chuili "Quay dAu tai d6i dien ngO XA Dan 2" se dirge coi 11 mOt ben, nhung re rang la khong tan tai ben nay. 3.Rieng von ben Yen Phil, con xuAt hien gia triYe'n Phu (Khoang 1), Yen Phu (Khoang 2) trong khi van chi la mOt ben.VAn de nay tuang to nhu da neu 0 moc 1 nhung khac 0 diem la khong xuAt hien dAu gach ngang trong chutoi can tach. 4.De ngAn each gift cac chit ngoii dAu citch ki to Non-breaking space cung dirge sir dung. Vi dAu each (ma ASCII he Map phan co gia tri: 32)va Non-breaking space (ma ASCII he thA'p phan co gia tri: 160) deu la ki to tring nen neu khong loai be ki to nay khi rAy du lieu du vao se clan den viec so sanh sal khi img dung host dOng. Vi do khi insert ten ben Long Bien vao co set dir lieu mac dia a sir dung ham trim() de xim ki to tang et din va cuoi chit& nhung ham nay chi xoa ki to space (du each) chic khong x6a Non-breaking space do de churn Long Bien va[Non-breaking space]Long Bien dugc coi la hai chu8i khac nhau dAn tai sai sat cho kat qua tra ve, Luang to film vay, neu chu8ixuAt hien dau cham cau (".") cling can phai loai b6. Giii phap cho vAn de nay nhu sau, ta se tao ra cac pattern de bat cat chubci gay nhieu tren, sau de dimg cap Pattern- Matcher de xi: 19 loai ba. Cac mAu tren bao germ: 1.Bat cac cum " (Yen Phu - Khoang 1)", " (Yen Phu - Khoang 2)" public final static String patternYenPhuKhoang = "\ (Yen Phu - Khoang [1-2]\\)"; 2. Bit cac cum "Quay dau Khasi lutin tot nghiep Trang 45Hg thOng tra ctiru thong tin tau xe Nguyen Hoing Long A10805 public final static String patternQuayDau = " -II }\\s*+Quay dinAss( (MPILM+ \\e-E[0-9]4)-R\s` ( (D P{L} \\sit; 3. Bit cac chutli " (Khoang 1)", " (Khoang 2)" public final static String patternKhoang = "\ (Khoang [1-2]\\)"; Rieng 1614 &roc ghdp voi the man Ichac to thanh mOt mau hoan chinh dE bit dugc tat ca cac chuoi da neu a tren va duori day la mau tong hop: public static Pattern ptrfrongHop = Pattern.compile (pattemKhoang "I" + patternQuayDau + + pattemYenPhuKhoang + "I" + "" + "I" + String.value0f( (char) 160)); N6i them vE Pattern, Matcher: Pattern va Matcher la hai lap thu6c package java.util.regex lam vi6c tren chu6i (string). Lop Pattern: mot d6i Wong pattern khi goi lenh compile se bie'n dich chuOi biEn thfre chinh quy de tang hieu suat cho qua trinh tim Iciem. Lop Matcher: d6i arcing matcher se dich pattern duot Bien dich a tren de" thtrc hi6n vi6c tim ki6m chu6i theo mau. Sau khi tim thay cac phan dr gay nhigu, ta se loai b6 chung bang each thay the the phan tin do bang dau cach. Sau buac nay ta se thu ducrc mOt chu6i da loai b6 nhiEu va chi con chu6i dai din ten cac ban va each nhau bing &Au "-" gach ngang. Thong thuimg, day ta se goi ham String.split() hoc Regex.Split() v6i tham so la dAu gach ngang "-", nhtmg tren chucmg trinh me phong Android (Android emulator) hai ham nay gay anh huOng 16n teri toe dO thuc thi cum chuong trinh. Nguyen nhan chinh la do mOi Ian goi String.split() thi bitu thirc chinh quy diu vao se dtroc bien dich lai do do lam chain qua trinh tim kiem chu6i.Giai phap cho yin d'E nay la ham du6i day: public static ArrayList<String> splitStation (String strArrLColumn) dau vao dm him la chuOi cac ben phan tach bang du cach, dau ra la mOt ArrayList kiEu string china ten ben da Lich. Ham nay lam vi6c nhu sau, yea m61 chat dau vao, n6 se kiEm tra tit vi tri tau (begin) den vi tri can (end) net xuAt hiOn ki to "-" thl cat lay xau truck dau "-" rSi dua vao ArrayList.Chu6i sau dau gach ngang se duce gan thanh Khaki luOn tot nghiep Trang 46He thOng tra dru thong tin tau lie Nguyen Holing Long A10805 chu&hien tai.T6c dO unix thi ham nay se cling Iftc cling nhanh visau m6i lin 14p, de dai cil a chu& can tim lai giam xuong. Den buem nay, de chuan bi cho viec insert vao co ser di lieu, ta se dinh nghia mOt 16p m6i ten la LookUpTable public class LookUpTable { private char element; private int begin; private int end; //Cau tir va cac phuong thirc set, get } 1‘46i del tuqng thuOc lap nay se ce du lieu la element: chit cai dau tien cua chu& begin: v1 tri dau tien xuAt hien char cai nay trong ArrayList end: vi tri cuoi cimg xuat hien chit cai nay trong ArrayList Khi insert ten ben vao ArrayList ta chi can so sinh chu6i de trong khoang vi tri bit dau tir begin vi ket thitc tai vi tri end ctia ArrayList. Neu ten ben da ce trong ArrayList thi khong can hru, nguqc lai thi no se duce luu vao ArrayList . Hinh dual day se mirth hqa tic dung dm ldp nay: 1 An Duicrng Vu'crng Bata ...'"A" 3 Bien Giang Bei ca xe Be• He 4 Be Trial., 5 BM d6 xe du Gray 6 Baia xe Kim M5 7 Chu Van An 8 Hinh 3.8. Mirth hga LookUpTable Gia sir ArrayList da cc:* cac ten ben nhu tren, trong qua trinh tach chu& ta lay chu& "BM d6 xe B& H6" dem so sanh veri gia tri cac ben nay. Lk nay, dei tuqng thuOc 16p LookUpTable cO gia tri element = se oft cac gia tri begin, end tucmg img la 2 vi 6. Chu& "Bai d6 xe 136 H6" se duqc so sinh tir v1 tri thir 2 den vi tri dui 6 ma Ichong can kiem tra den het ArrayList. 2 Khali lutin tot nghiep Trang 47He thOng tra cum thong tin tau ze Nguy;n Holing Long A10805 3.7. Cid (14 cic chirc rang chinh Choir ndng Chuyin tuyin So do hanh dOng cita chirc tang nay duce minh hga clued day • CShip UM au )(am Mn cuff V (In unman Man Hinh 3.9. Sod& hank dOng chirc ning chuyen tuyen Khi ngued clangchgn nhAp ben dAu hoc ben cu6i, img dung deu dua ra gqi y cho cac chu6i nhap vao neu co chu8i hqp 1e. Tinh ning nay co ho trg tieng Viet nen ngtriri thing c6 the g6 nhang chft Ichong dau hoc co dau co trong ten ben sau do dua vao gqi de" chgn ra ben theo yen cAu. Vi du, neu ben Idled Brill IA BA Trieu, ngtrai dung ge "B" vi chqn trong danh sach cac ben co chu "b" nhu Ba La, BA Trieu,... Khi ngued dfing ham nut "Xem", ben di se fro thanh diem dAu, thong qua thuAt town Dijsktra se tim dugc duang di ngan nhat too diem al& tirc ben den, neu din tai duerng di giaa 2 diem nay. DO' lieu Au vao cho thuat toan Dijsktra dtrqc m6 hinh hem dual clang ca sot du lieu co the ducor m8 to tong quat bang hinh minh hga dyed day. IC.h6a luOn tot nghiep Trang 48H§ thong tra aim tinting tin tau lie Nguygn Holing Long A10805 BQn Tram s6 E Dam 1ti n /1 > / Hinh 3.10. Minh hoa mo hinh hoa dry lieu Ta coi cac ben la cac dinh cua do thi, th8ng tin ve ben trot luu tai bang Ben. Hai ben too nen 1 doan tuang img vai canh cua do thi, thong tin nay duqc luu tai bang Doan, bao gam gia tri Ich6a cita ben tram, gia tri khoa cita ben sau, tong so, chieu... C3 day, tong s6 la khoitng each gifta 2 ben, chieu dac trung cho hunng di hay ve elm doan. Vi du, Tuyen A den E co chieu di la thi thong tin ve doan A — Btrong ca so dit lieu se duce km nhu sau (gia sir kh6a dm A la 1, B la 2, tong so la 1): IDBenTruoc: I IDBenSau: 2 Chieu: 0 TrongSo: 1 'Chi co nguoi dung nhap vao ben di va ben den, du lieu ye phan do thi dun cac doan ket not gift hai dinh nay se duqc luu tra trong cat trim Priority Queue (hang dqi uu tien). Viec nay Maul chain bi cho thuat toan Dijkstra host dongtheo kieu "Giam Muria" (decrease key). Co nghia IA, vol moi dinh nam b &Au hang dqi uu tien, sau khi cap nhat gia trikhoang each ten the dinh k'e no, no se bi day ra kh6i hang dqi. De tim duqc trinh tu chuyen tuyen, to se Mu vet &rang di va va lay ra dtrqc cac doan not giaa hai dinh dau/cu6i dam bao you au yeti so fan chuyen tuyen it nhat.Cach thirc lam viec chi tiet ctia cua chtic nang nay dtrqc trinh bay co the sau day. A 4 Tuygn 'Chita Juan tot nghib Trang 49cfaioa than OGnO•Iod• colLIIIOnpotesioSporaon nava anon> GIG'S •visladlkalas: Arraytishastaosa eGraph(Grflatavaa) •oelStariNode0DnitalS•ia •gstalorleaDanylat•DrapalloOav nOscaverGraphOc•DS nbfalOtar•NadaS••• nWategeraphtlodatbaalaan nvial(GrapMladayvaid •Priag0•0•3 v•Java Caws Ed9e oan koamsgertoloahlOpor *MI a cast Mew a kFlotrav Yager eacige(GraantiodeasklarOtager) •getN00•0:01100100 •gelCsatollacer •oaddRautnaintagat oinodaCount at a vat Maw a D Mtge, •• Allot bootee •Stance: Mar otoosom000thosoon of orap000don •a101tagar):vekl •satVlated(Ocrolaan)vald •AddthapergEoga(GraPaNadeadagavalsoaryna •plOulGoiwEOgasia.Anastil•Ettge. •geNaatlitagar •saNaaslaoac)voitl •tlantatiter •caspacalb(GrapaNadatEd •gatOiliantwOlaallsc •salOtance(MaprOold ---otocee3 0. • • poueue o • aJavt Oman laGroplConstoots cowed ouroonoposoporanoo VItoiaw. Otero of GraohConstaMS0 "lava Clasen eGsaybNodaPrI041000•1111 aantslarosmaloalm apse eGraraloO•Prisly0mas0 •aScl(DcaPtiasSarcad •acklOCabactim•GraptiNeOr•Yvaal •Sastiongteolaan •cemovaDtkaahlioda •updsteGraphitocleOlitancapaphtIodaSvoi •PreraMSO:••• He thong tra cvu thfing tin tau lie NguyAn Holing Long A10805 Hinh 3.11. Cic lap h6 trq thuat town Dijkstra De c6 the lip ding thuat tom Dijkstra vio bpi toin ta can xay thing cac lap h6 trq sau: Graph: luu tit th8ng tin va cac phucmg thCrc Wong tic veri danh sach cac node thuOc cling met a thj(allNodes), cac node da &roc duyet qua(visitedNodes) va node kheri dau dm qua trinh tim duang di ngan nhat(startNode). —GraphConstants: chin hang s6 khi kheri tao d6 thj a day la INFINITY =999999, tirc 11 Luang ducmg vow khoing cach giera 2 node la vo ding tr'en ly thuyet. —GraphNode: chin town be thong tin cut melt node trong do thj bao gam, ten, ID, tinh tang da duce duyet hay chua, danh sach cac dinh ke. Ngoai ra 16p nay con chCra dinh nghia cut lap Edge(canh). Lem nay chtia th8ng tin vE node, tong so hay "gia", va ID dm mot canh(tirc la doan n6i giita hai ben). —GraphNodePriorityQueue: china do thj de phoc vu viec tim cluing di ngan nhat gi8a 2 node theo kieu "Gam khea" (decrease key). Sau khi co cac lap h6 trq, ta xay (long lop Dijkstra de ket hop cac lop nay de xi: ly thong tin va dua ra phircrng an chuyen tuyen ngAn nhit. Ta can co met d6i tuctng co the ltm lai vet clueing di dm met node de co the in ra cac thong s6 can thiet ve tuyen dtremg(TraceList). Cac gia trj nay bao g6m ID caa node hien tai(currentNode),ID cua node truerc n6(prevNode), ID dm canh not hai node nay(idRoute). Den bucrc nay, a tim ra phirerng an chuyen tuyen ngin Mat ta tien hint' theo trinh to sau: Trang 50 Khali lu(in hit nghiepHg thiing tra city th8ng tin tin xe Nguyen Hoing Long A10805, 1.Chay thuat loan Dijkstra de tim ra khoang each ngin nit& gifra 2 ben da chgn. 2.Chay lai thuat toan Dijkstra nal kiem tra tuyen throng vol khoang cach da tim dugc, eking thin luu lai vet cua m6i tuyen. 3.Tim ra phiscmg an co so Ian chuyen tuyen ngan nhAt trong danh sach dirge tim ra 6 buck 2. CS day can giai thich ki hon butrc 2, vi sao lai phai chay lai thuat toan Dijkstra 1 lAn nfra? Nguyen nhan la do co the tan tai nhieu phtrcmg an chuyen tuyen co khoang each nein nhat nhtmg s6 lan chuyen tuyen lai kh8ng ngan nhAt. Ta se thAy r6 hon qua vi du sau: Gia sir ta muan di chuyen tir ben A den ben F, gift A va F co ba phuong an chuyen tuyen ngin nhAt nhu sau +A-E-F +A-B-C-F +A-C-D-C-F Mac du 3 hp chgn nay dell dat tieu chi co tang quang cluimg la ngan nhAt nhung s6 Ian chuyen tuyen thi lai khac nhau. Vi vay ta can phii chay lai thuat toan *It l'An flea de' Wu lai tat ca cac danh sach vet dtrimg di rai sau de kiem tra de tim ra dugc phucmg an co so ran chuyen ben la it nhAt. Char ming Dinh vj Chirc nang nay se hien thi vi tri hien tai cua ngutd dung thong qua GPS va Google Map eking thin cho phep tim kiem cac ben xe butt gAn vi tri hien tai. De lam dugc vies nay, ta se sir dyng Google Map API for Android vi Google Place API. Day 11 2 API (Application Programming Interface — giao dien lap trinh img dung) manh me va ha trq rat tot cho lap trinh vien, trong do Google Map API cung cap th6ng tin ve cac loai ban d6 (giao thong, ve tinh...) con Google Place API cho thong tin ve dia diem (ben xe, quart Vi phien ban Google Map hien tai la V2 (version 2) khong cho phep chay tren may mo phong (Emulator) nen ta phai kiem tra hoat dOng trenthiet 131 that.Chtic nang nay hoat dOng nhu sau: dien thoai th8ng qua tinh nang GPS se ket not vai vg tinh GPS de lAy ra 2 gia tri la longitude — kinh dg va latitude — vi r6i ket not yeti Internet, thong qua Google Map API se giri du lieu nay den may chit cua Google, sau do no se giri lai du lieu la mOt MapFragment. Day la mOt phan hinh anh chira thong tin ve vi tri hien tai cua ngutri sir dung, dutmg sa khu vtrc xung quanh... Khi nguOi dung barn vao nut "Ben xe butt", qua trinh girl va nhan du lieu ding ttrcmg tu nhu tren de lity th8ng tin ve ban do, ding tiled thuc hien them mOt bulk nfra la th8ng qua Google Place API de lay du lieu ve Kit& 1u4n vat nghiep Trang 51.He thong tra colt thfing tin tau ae Nguyen Hoing Long A10805 dia diem. C3 day la cac ben xe buYt trong pham vi dinh sin gin vii vi tri hien tai cita nguei &mg. De sir dung duqc Google Map API va Google Place API, ta phai dAng Ici sir dung dich vu vdri Google theo cac buerc sau: Hinh 3.12. Lay debug keystore Debug keystore la mOt ma SHA-1 sinh ra tir file debug.keystore. Simple API Access Use API keys to identify your project when you do not need to access user data. I earn more Key for Android app. (with certificates) API key: AlzaSyBXRDIj6t2rFDhtneL3Ed2urG15DItt3al7k Android apps: 19:132 :23 :D1 : 29:28: 913: - • 67 : DE: 2F: cam. 01 . trannortationhelper Activated on: May 6, 2013 3:26 AM Activated * viosani.lovosasnirnegmatcom - you Hinh 3.13. Lay API key Sau khi nhap Debug keystore va ten project(cich nhau b?ri &Au ";") ta thu duce API key nhu hinh tren. Cu& ding, ta dua }diem nhan duqc vao file AndroidManifest.xml nhu sau: <meta-data android:name="com.google.android.maps.v2.API_ICEY" android:value="@string/myGGAPIKey" Veri myGGAPIKey la API key duce dinh nghia 6 file res/value/strings.xml. Sau khi thuc hien thanh cong cac bulk tren, ta da sin sang cho viec sir dung Google Map API vi Google Place API. CS chirc nang Dinh vi, a lay duce thong tin ve dia chi dm vi tri hien tai, ta se ip dung ki thug Reverse geocoding. D6 la qui trinh nem lugng va tri ve thong tin dia chi gait veri toa d6 cho truerc. Do day la qui trinh uerc Krung, dua tren lchoing cich den mOt toa dO nhat dinh nen, ket qui tra ve c6 the chi li Ian dting(gan veri vi tri cho trix6c) hoac Ichong tim duqc dia chi nao. CS chirc nang Ben xe buyt, khi ngueri dimg kich hog chirc nang nay bang each bam nit "Ben xe buYt", mOt lenh troy van dfr lieu duqc girl den Google server duoi dang HttpURLConnection yen Mu vao la mOt chutii duqc xily dung nhtr sau: String type = "bus_station"; Kit& 1u4n hit nghiep Trang 52Hg thong tra cut tilting tin tau xe Nguyen Holing Long A10805 StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?"); sb.append("location=" + mLatitude + "," + mLongitude); sb.append("&radius=2000"); sb.append("&types=" + type); sb.append("&sensor=true"); sb.append("&key—AlzaSyBOLgovejjoCBqy4Gc43GyCa- pm5GkYxU"); Trong do: —location: IA tqa dO cua vi Hi hien tai —radius: IA khoing cach(ban kinh) toi vi tri hien tmi tinh bang don vi met(m) —type: IA kieu vi tri can tim kiem thong tin —key: IA khea de sir dvng djch vv Google Place Ket quA tra ve cua cau lenh nay IA met ded tuqng Json(Json Object). DOi ttrgng nay se china met danh sach cac dia diem cimg veri thong tin lien quan tdd dia diem do. Ved tieu chi dat ra o day IA tim cac ben xe buyt trong khoing cach 2000m quanh vi tri hien tai thi, d6i tugng Json litc nay se china thong tin ve cac ben xe bujyt xung quanh vi tri d6 trong khoang 2000m. DE lay dugc thong tin dm d6i tucmg nay, to can met lop ho trq la PlaceJSONParser. Lop nay se doe vio met did tuqng Json va tra ye danh sach cac dia diem vA thong tin di kern veri no rum s6 nhA, duang ph6, quan huyen... Kb& luiln tot nghiep Trang 53I? fining tra dru tilling tin tau lie Nguyen Holing Long A10805 3.8. CAu hinh 1.CAu hinh phIt triers Eclipse 4.2, Java 1.6 va Android 4.2, Google Map API v2 cho Android, Google Place API 2.au hinh tOi thieu: - Google Play services 3.0.25 (583950-10) - Android 2.3.3-2.3.7 Gingerbread (API level 10) - CPU 830 MHz ARMv6 - Ram 290 MB -1-16 trq GPS - CO tinh nAng WIFI hoac WO trq 1(61 not Internet 3.du hinh de nglii: - Google Play services 3.0.27 (599131-10) ho4c mai ban -Android 4.1 Jelly Bean (API level 16) - CPU tir 1Ghz tit len - Ram dr 500 MB ter len - HiS trq GPS - Co tinh nang WIFI ho4c WO trq ket n6i Internet Khoo loan tot nghiep Trang 54Hg thong tra cum tilling tin tau xe Nguyen Holing Long A10805 CHICONG 4. KeT MAIN VA HIANG PHAT TRIEN Ved y Wang ban Mu la thnt hien khela luen v6i de tai: "Xay dyng ph An mim hogs dfing trin he diiu hanh Android, he try ngwiri ding tim ra cdch di chuyin gift Sc bin xe Ngc du phai to tim hieu ve met kith niem hoan man meri me la he dieu hanh Android, nhung tic gia di co ging nghien eau va trinh bay met each chin thac nhit nhang hieu biet cua minh ve cac van de co thuOc khuon kh6 cua khem luin nay. Veri tinh nang Chuyen tuyen, do ly do khtich quan la khong the tim duot be du lieu chi Wet ve khoang each gifta cac tuyen nhung tic gia di hoan thank phin nay theo huemg tim ra each di chuyen giaa 2 ben xe bujit ma so lin chuyen ben la it nhit, ding th6i ca so der lieu duqc thief k'e theo huemg mer (co truiing Trang s6), truing nay se phuc vp cho viec tinh toan chinh xk each di chuyen ngin nhat duavao khoang each giita cfic ben neu co duce bo clit lieu chi tiet. Ben canh do, tinh fling Dinh vi cling dem den kha ning mer rung cho chinh no. Vi host dOng dtra tren Google Map API va Google Place API nen kha nang be sung ck tinh nang meri la rat kha thi va hai API nay dirge cap nhit thutmg xuyen nen khi dirge mer rOngtinh !ling nay se co kha nang dip an duce you caw aim ngutri &mg. Mic do nghien cum met linh vut men, nhung tic gia di luem nhin dugc sa ho tay ve tai lieu va kien that tir ck thay co va stir dOng vien chia se tir ban be de tic gia co the hoan thanh khea luin nay. Xin chin thanh cam an! Khali 14a tilt nghib Trang 55NguyZn Hoing Long A10805 H'4 thiing tra cvu thong tin tau xe PHy LyC 1- CAC THUjT NG* 1.HTML: HTML la chfr viet tat dm Hyper Text Markup Language (Ng8n nger hien thj sieu van ban). - Met file HTML 11 met file text bao g6m nhUng tag nhe - Nhfing tag hien thj n6i cho trinh duyet biet ne phai hien thj trang do nhu the nio - Met file HTML phai co phAn ma reng 11 .htm hoac .html -Met file HTML c6 the duce tao bed met trinh soan thao don giin. Cau true co ban cila 1 file HTML c6 clang nhu sau: <HTML> <HEAD> <TITLE> Ten trang </TITLE> </HEAD> <BODY> <!-- Van ban va cac the HTML --> <BODY> </HTML> 2.DOM: la met mo hinh cho phep truy xuAt den cac thanh phAn dm met tai lieu ce ciu frac. Viet tit cua( Document Object Model ), dirqc ha try bai hail het cac trinh duy8t ne cung cap cac D6i Wong , Phucmg thfrc, Thuec tinh truy xuat cac tai lieu HTML, XML , XHTML. Kh6a loan tot nghiep Trang 56Document Root element: <html> Attribute: "href" Element: <body> Element: <title> Text: "My title" Element: chi> Text: "My header" Element: <head> He thong tra cdru thOng tin du xe Nguyen Holing Long A10805 Minh hqa DOM dm file HTML. 3.Jsoup: la met thu vien Java lam viec v6i HTML. NO cung cap cac phucmg that tien lqi de trich xuet va thao tac vOi dor lieu duce t6 chirc theo kieu DOM. Vi du ve viec thy dB lieu dung Jsoup : File input = new File ("/tmp/input.html"); Documentdoc = Jsoup.parse (input, "UTF-8", "http://example.com/"); Element content = doc.getElementByld ("content"); Elements links = content.getElementsByTag ("a"); for (Element link : links) String linIcHref = link.attr ("href"); String linkText = link.text 0; } Trong vi du nay, file "input.html" se dtrqc dqc va lint vao dei tucmg doc kieu Document, tir d6 thy ra cac dutmg cthn Uri web co trong file nay. 4.SSL (Secure Sockets Layers): Viec ket not gift met Web browser tai bit Ict diem nao tren mang Internet di qua rat nhi'eu cac he Oiling dee lap ma kitting co bit IcY su bao ve nao v6i cac thong tin ten Khea luCin tot nghiep Trang 57Hg thilong tra cum thong tin tau xe Nguyen Holing Long A10805 throng truyen. Khong mot ai ke ca ngueri sft dung Ian Web server co bat ky so kiem sodt nao doi veri duerng di dm du lieu hay co the kiem sodt duqc lieu co ai dO than' nhap vio thong tin teen &rang truyen. De bio ve nhamg thong tin mat tren mpg Internet hay bat ky mgng TCP/IP nao, SSL da ket hop nhang yeu t6 sau de thiet lap duk mot giao dich an town: - Xac thoc: dam bao tinh xac thoc cua trang ml ban se Ilm viec a dau Ida aid ket n6i. Cling nhu vay, cac trang Web ding can phai kiem tra tinh xac thoc cad ngued sir don. - Ma hoa: dim bao th8ng tin kh6ng the bi truy cap bed doi arcing thir ba. De loci trir viec nghe from nhftng thong tin " nhay cam" khi no duk truyen qua Internet, du lieu phdi duce ma hod de kh8ng the bi dog duqc beri nhimg ngueri khk ngoAi nguen giri va ngueri nhan. - Toan vgn du lieu: dam bdo thong tin khong bi sai tech va no phai the hien chink xac th6ng tin DSc giri den. 5. Geocoding (tim kiem theo ilia chi) MOt doi ttrgng tren ban do bao gib ding duqc bieu dien bang met kieu da lieu de hog. Phan d6 hog nay co the thu dirk bang cach s6 hob hay quet Anil ban d6. Tuy nhie'n, khi ta da co ban d6 (ban M s6), chin ta cling co the xac dinh duqc phan dft) hog bieu dien doi tuong hay IA vi tri, hinh dung dm doi tuong thong qua ck du lieu mo ta vi tri cod no vi du: so nhA, ten duftng, ten quan... Geocoding (hay address matching) la mot tien trinh nhim xac dinh cac doi tugng tren co ser mo ta vi tri cua chling. Day IA met ky thuat rat nei tieng, co mat trong rat nhiEu img clung dm GIS. Ngtreri ta ggi met geocoding service IA qua trinh chuyen doi town be me to thuec tinh ve vi tri sang mo ta kh8ng gian. DE tim dugc vi tri thong qua dia chi, geocoding service phai tham chieu den it nhit met nguan da lieu bao gem ca thong tin ve dia chi (thuOc tinh) va thong tin kh8ng gian (vi tri, hinh dang).DD lieu nay dirk goi IA du lieu tham chieu.Cac geocoding service co the thao tag tren nhieu kieu dft lieu tham chieu khac nhau. Sau khi da geocoding de lieu tham chieu (tirc la anti xg mo ti thuOc tinh vio mo ta Ichong gian). Ta co the nhap dia chi dm d6i Wong can tim. Quy trinh xfr 1ST trai qua cac buesc sau: Chuan hob gib tri dia chi vita nhap vio bang each Lich no thanh cac thanh phan dia chi nh6. Kluria lutin tat nghiep Trang 58Hg thong tra min thong tin du xe Nguyen Holing Long A10805. Geocoding service sau d6 se tim trong nguan du lieu tham chiau de xac djnh cac doi tugng c6 cac thanh ph'an dja chi turmg img vgi du lieu nh4p vao.Moi kiau geocoding service se quy djnh cac djnh clang cua cac DAM pit dia chi nay. Tlap kat qua tra ve se dugc gan cac tong s6 (diem) de tim ra ket qua gin dung nhit. Geocoding service se danh dau dai tugng vita duct tim thay tren ban do bing mOt d6i tugng d6 hoe. IChtia loan tot nghiep Trang 59kHg &Ong tra cum thong tin tau lie Nguyen Holing Long A10805 PHy LyC 2 - DANH MyC TAI LIetl THAM KHiO TM lieu tang Viet 1.Quyet dimh s6 1327/QD-TTG, Quy hooch phcit trien giao thong van tai &tang 6'0 Viet Nam din nam 2020 va dinh Throng din elm 2030, Thu tuOng Chinh 2.Nguy6n Vi4t CuOng, Tuyin bus Ha NOi, Trtrtmg Dai Hoc C6ng Ngh6 - Dpi HQC Qu6c Gia Fla N0i, 2012. 3.Tr'an Xuan BO, EBUS 2.2 — Phan mem trp gizip di xe Bus 10 Ha Hai va Ha Chi Minh, 1/2010. Tai lieu tang Anh 1.Wei Meng Lee, BeginningAndroidTM Application Development, Wiley Publishing Inc., 10475 Crosspoint Boulevard Indianapolis, 2011 2.Reto Meier, Professional AndroidTm Application Development, Wiley Publishing Inc., 10475 Crosspoint Boulevard Indianapolis, 2009 Khali Iu4n tot nghiep Trang 60

- Xem thêm -

Tài liệu liên quan

Bình luận