SlideShare a Scribd company logo
TRUNG TÂM TIN HOC – ĐẠI HỌC KHOA HỌC TỰ NHIÊN – ĐẠI HỌC QUỐC GIA TP. HỒ CHÍ
                                  MINH

                     Bộ Phận Lập Trình Di Động – Lập Trình Android




      Báo Cáo Tốt Nghiệp Khóa Lập Trình Android Cơ Bản
   Đề Tài:




                                                     Học Viên:Nguyễn Xuân Dương
                                                              Huỳnh Đức Vinh

                                                     Lớp:Android tối 2,4,6

                                                            Giáo Viên:Bùi Quốc Ánh
Nội Dung:
I.Giới thiệu
1.Đề tài
       Chương trình sử dụng webservice lấy thông tin về tất cả thông tin động đất
trên thế giới và show lên giao diện.

2.Phân tích và mô tả đề tài
       Đề tài sẽ thực hiện những yêu cầu sau:
a.Xử lý:
       _Gửi requests lên service để lấy thông tin về động đất từ server về.
       _Xử lý thông tin lấy về (cắt những thông tin cần lấy bao gồm ngày, nơi,
matitude ,latitude và longtitude) rồi lưu vào contentprovider.
       _Các thao tác lấy data và lưu data ở trên sẽ được thực hiện thông qua 1
service chạy ngầm.
       _Listview (main Activity)sẽ dùng để hiển thị thông tin động đất lên màn
hình .Listview sẽ lấy dữ liệu từ content provider.
b.Chức năng:
       _Khi click vào 1 row trên listview sẽ hiển thị thông tin chi tiết của trận động
đất thông qua đối tượng dialog.
       _Khi click menu (option menu) sẽ có 2 chức năng là refresh và references
.Refresh dung để load lại dữ liệu từ data lên listview .Chức năng reference dung để
chọn chế độ update tự động hay không và thời gian update tự động là bao lâu đồng
thời hổ trợ thêm 1 filter để lọc ra những trận động đất lớn hơn giá trị đưa vào.


II.Thuật toán
1.Lấy dữ liệu từ server (dưới dạng XML):


public void doRefreshEarthquakes()

{
      try{
URL url = new URL(
            "http://earthquake.usgs.gov/earthquakes/catalogs/1day-M2.5.xml");
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(new InputSource(url.openStream()));
      doc.getDocumentElement().normalize();

      NodeList nodeList = doc.getElementsByTagName("entry");
                  //Log.i("test",);
            /** Assign textview array lenght by arraylist size */

      for (int i = 0; i < nodeList.getLength(); i++) {

            Node node = nodeList.item(i);

            Element fstElmnt = (Element) node;
            NodeList idList = fstElmnt.getElementsByTagName("georss:point");
            Element idElement = (Element) idList.item(0);
            idList = idElement.getChildNodes();

            String point=((Node)idList.item(0)).getNodeValue();
            String[] location = point.split(" ");
            Location l = new Location("dummyGPS");
            l.setLatitude(Double.parseDouble(location[0]));
            l.setLongitude(Double.parseDouble(location[1]));


            NodeList titleList = fstElmnt.getElementsByTagName("title");
            Element titleElement = (Element) titleList.item(0);
            titleList = titleElement.getChildNodes();

            String details=((Node) titleList.item(0)).getNodeValue();
            String magnitudeString = details.split(" ")[1];
            int end = magnitudeString.length()-1;
            double magnitude =
Double.parseDouble(magnitudeString.substring(0, end));
            details = details.split(",")[1].trim();


            NodeList dateList = fstElmnt.getElementsByTagName("updated");
                        Element dateElement = (Element) dateList.item(0);
            dateList = dateElement.getChildNodes();

            String dd=((Node)dateList.item(0)).getNodeValue();

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-
dd'T'hh:mm:ss'Z'");
            Date qdate = new GregorianCalendar(0,0,0).getTime();
            try {
                  qdate = sdf.parse(dd);
            } catch (ParseException e) {
                       e.printStackTrace();
            }

            NodeList linkList = fstElmnt.getElementsByTagName("link");
            Element linkElement = (Element) linkList.item(0);
            linkList = linkElement.getChildNodes();
String link1=linkElement.getAttribute("href");

           Quake quake=new Quake(qdate, details, l,magnitude, link1);
                       //lay 1 doi tuong moi ve
           addNewQuake(quake);

           }
           } catch (Exception e) {
           System.out.println("XML Pasing Excpetion = " + e);
           Log.i("test", "null pointer");
           }

      }




II.Thực hiện
1.Code chương trình
a.Sơ đồ tổng quát




                             Option Menu            References
       ListView

    (Main Activity)                              (atoupdate và filter
                                                   theo matitude)



loadQuakesFromProvider()                       lọc thông qua reference
                             bắn lên Intent


    Contentprovider                                   Service
                             lưu data
Send                 get


             Qake

                                                             Internet




b.Code
      Ở đây sẽ trình bày theo từng lớp và sau đó là mối liên kết giữa chúng.
b.1Các lớp
      _Quake class: là 1 đối tượng lưu các thông tin của 1 đối tượng Quake bao
gồm: date(kiểu date time),longtitude(long),latitude(long),matitude(long),
area(String).




        private   Date date;
        private   String details;
        private   Location location;
        private   double magnitude;
        private   String link;




      _EarthQuake2011V1Activity class: là một main Activity dùng để hiển thị
thông tin của Quakes lên màn hình.

EarthQuake2011V1Activity
_updateData()
    +Start service
_updateFromReference()
    +Lấy các thông số lưu vào references trong lớp Reference để filter ,xử lý.
_addQuakeToArray()
     +add 1 đối tượng quake vào earthquakes array.
 _loadQuakeFromProvider()
     +Lấy dữ liệu từ provider lên theo từng row rồi đổ vào đối tượng quake(1 row
trong provider sẽ được lưu vào 1 quake )tiếp đó là add quake vào quakes array
(thông qua hàm addQuakeToArray())
_EarthQuakeBroadCastReceiver class:lớp này này kế thừa từ BroadcastReceiver
dùng để bắt lấy intent bắn lên từ sevice khi có 1 quakes mới được update.


Ngoài các phương thức trên thì lớp này còn override lại 1 số phương thức của
Activity để tạo option menu,và dialog.
       _EarthQuakeProvider class:lớp này kế thừa từ Contentprovider class dùng
để tạo database và cung cấp 1 số phương thức để thao tác dữ liệu.


// Column Names
  public static   final   String   KEY_ID = "_id";
  public static   final   String   KEY_DATE = "date";
  public static   final   String   KEY_DETAILS = "details";
  public static   final   String   KEY_LOCATION_LAT = "latitude";
  public static   final   String   KEY_LOCATION_LNG = "longitude";
  public static   final   String   KEY_MAGNITUDE = "magnitude";
  public static   final   String   KEY_LINK = "link";

private static final String DATABASE_CREATE =
      "create table " + EARTHQUAKE_TABLE + " ("
      + KEY_ID + " integer primary key autoincrement, "
      + KEY_DATE + " LONG, "
      + KEY_DETAILS + " TEXT, "
      + KEY_LOCATION_LAT + " FLOAT, "
      + KEY_LOCATION_LNG + " FLOAT, "
      + KEY_MAGNITUDE + " FLOAT, "
      + KEY_LINK + " TEXT);";


@Override
  public Cursor query(Uri uri, String[] projection, String selection, String[]
selectionArgs, String sort) {

}

@Override
  public Uri insert(Uri _uri, ContentValues _initialValues) {

}

@Override
public int delete(Uri uri, String where, String[] whereArgs) {

}

@Override
  public int update(Uri uri, ContentValues values, String where, String[]
whereArgs) {

}




        EarthQuakeService class:kế thừa từ lớp Sevice chạy ngầm gửi request và
        _
lấy data từ server.Sau đó lưu dữ liệu xuống provider.


EarthQuakeService
_refreshEarthquakes()
    +Start 1 new thread thực thi hàm bachgroundRefresh().
_backgroundRefresh() là 1 Runable
     +Override hàm void run() và thực thi phương thức doFreshEarthQuakes().
_TimerTask doRefresh()
     +Thực thi phương thức refreshEarthquakes() trong hàm run .
_onStart()
     + Các hàm trên sẽ được sử dụng khi ta chọn chế độ auto update trong
References.Nếu không update tự động thì sẽ gọi hàm doRefreshEarthQuake()
_doRefreshEarthQuake():
    +Sẽ thực hiện kết nối với server để lấy dữ liệu về sau khi lấy về sẽ đổ dữ liệu
vào đối tượng Quake rồi add vào provider.
_addNewQuake()
     +Hàm này dùng để add dữ liệu vào provider
_announceNewQuake()
     +Hàm này sẽ được bắn lên nếu có 1 quake mới được lưu vào provider
     +Trong hàm này ta thực thi 1 status notification để khi có 1 quake mới được
cập nhật thì status này sẽ bắn lên thông báo cho người dùng biết.




2.Giao diện
a.Màn hình chính: sẽ hiển thị danh sách các earthquakes
b.EarthQuake details:khi click vào 1 row trên listview sẽ hiển thị dialog để show
details
c.Option Menu: gồm 2 chức năng là refresh và reference.Refresh sẽ load lại data từ
provider.Còn Reference thì sẽ set các chết độ auto update và filter theo matitude.
*Reference
*Màn hình sau khi filter với matitude bằng 5:

More Related Content

Viewers also liked

Productivity Is Killing Us SDEC14
Productivity Is Killing Us SDEC14Productivity Is Killing Us SDEC14
Productivity Is Killing Us SDEC14
Adam Yuret
 
Ngân hàng vs rút tiền hàng loạt
Ngân hàng vs rút tiền hàng loạtNgân hàng vs rút tiền hàng loạt
Ngân hàng vs rút tiền hàng loạt
ecoblader
 
Busyness geekfest
Busyness geekfestBusyness geekfest
Busyness geekfest
Adam Yuret
 
Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...
Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...
Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...
Peter Goodburn
 
Presentation1.html
Presentation1.htmlPresentation1.html
Presentation1.html
Amurusha Kennedy
 
Gavin
GavinGavin
Gavin
benock
 
Ensayo bien b
Ensayo bien bEnsayo bien b
Ensayo bien b
Miri A. AlvareZz
 
problemas con las tics
problemas con las ticsproblemas con las tics
problemas con las tics
Miri A. AlvareZz
 
Value Stream Mapping LASCOT 2014
Value Stream Mapping LASCOT 2014Value Stream Mapping LASCOT 2014
Value Stream Mapping LASCOT 2014
Adam Yuret
 
Busyness lascot15
Busyness lascot15Busyness lascot15
Busyness lascot15
Adam Yuret
 
A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015
A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015 A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015
A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015
Adam Yuret
 
Busyness Agile Roots 2015
Busyness Agile Roots 2015Busyness Agile Roots 2015
Busyness Agile Roots 2015
Adam Yuret
 
The Art of Program Development
The Art of Program DevelopmentThe Art of Program Development
The Art of Program Development
mikespezzano
 
It report
It reportIt report
It report
tersurmd
 
Agile leadership (SeaSpin 05/2015)
Agile leadership (SeaSpin 05/2015)Agile leadership (SeaSpin 05/2015)
Agile leadership (SeaSpin 05/2015)
Adam Yuret
 
"Productivity" is Killing Us.
"Productivity" is Killing Us. "Productivity" is Killing Us.
"Productivity" is Killing Us.
Adam Yuret
 
Showmybuy kista 2013
Showmybuy kista 2013Showmybuy kista 2013
Showmybuy kista 2013
niclaslindberg
 

Viewers also liked (17)

Productivity Is Killing Us SDEC14
Productivity Is Killing Us SDEC14Productivity Is Killing Us SDEC14
Productivity Is Killing Us SDEC14
 
Ngân hàng vs rút tiền hàng loạt
Ngân hàng vs rút tiền hàng loạtNgân hàng vs rút tiền hàng loạt
Ngân hàng vs rút tiền hàng loạt
 
Busyness geekfest
Busyness geekfestBusyness geekfest
Busyness geekfest
 
Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...
Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...
Track Record - Stock Indices | Forex | Fixed Income & Commoditied - WaveTrack...
 
Presentation1.html
Presentation1.htmlPresentation1.html
Presentation1.html
 
Gavin
GavinGavin
Gavin
 
Ensayo bien b
Ensayo bien bEnsayo bien b
Ensayo bien b
 
problemas con las tics
problemas con las ticsproblemas con las tics
problemas con las tics
 
Value Stream Mapping LASCOT 2014
Value Stream Mapping LASCOT 2014Value Stream Mapping LASCOT 2014
Value Stream Mapping LASCOT 2014
 
Busyness lascot15
Busyness lascot15Busyness lascot15
Busyness lascot15
 
A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015
A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015 A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015
A Twenty-Minute Intro to Scrum Lean Agile Scotland 2015
 
Busyness Agile Roots 2015
Busyness Agile Roots 2015Busyness Agile Roots 2015
Busyness Agile Roots 2015
 
The Art of Program Development
The Art of Program DevelopmentThe Art of Program Development
The Art of Program Development
 
It report
It reportIt report
It report
 
Agile leadership (SeaSpin 05/2015)
Agile leadership (SeaSpin 05/2015)Agile leadership (SeaSpin 05/2015)
Agile leadership (SeaSpin 05/2015)
 
"Productivity" is Killing Us.
"Productivity" is Killing Us. "Productivity" is Killing Us.
"Productivity" is Killing Us.
 
Showmybuy kista 2013
Showmybuy kista 2013Showmybuy kista 2013
Showmybuy kista 2013
 

Similar to Android report

Thuc hanh ado.net_bai_03
Thuc hanh ado.net_bai_03Thuc hanh ado.net_bai_03
Thuc hanh ado.net_bai_03
Thanh Điền
 
Semina Kết nối nguồn dữ liệu từ Internet
Semina Kết nối nguồn dữ liệu từ Internet Semina Kết nối nguồn dữ liệu từ Internet
Semina Kết nối nguồn dữ liệu từ Internet
Nguyễn Ngọc Hoàng
 
Lập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biếnLập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biến
Son Nguyen
 
ChatMessenger
ChatMessengerChatMessenger
ChatMessenger
Diên Vĩ
 
Dsd05 02b-json-rpca
Dsd05 02b-json-rpcaDsd05 02b-json-rpca
Dsd05 02b-json-rpca
Văn Đào Tiến
 
Net06 asp.net applications & state management
Net06 asp.net applications & state managementNet06 asp.net applications & state management
Net06 asp.net applications & state management
hoangnguyentien
 
Bai3 basic servlets_956
Bai3 basic servlets_956Bai3 basic servlets_956
Bai3 basic servlets_956
Ham Chơi
 
Jniについて
JniについてJniについて
Jniについて
Chu Chu
 
7.databinding
7.databinding7.databinding
7.databindingDao Uit
 
MVC
MVCMVC
MVC
tkot
 

Similar to Android report (20)

Thuc hanh ado.net_bai_03
Thuc hanh ado.net_bai_03Thuc hanh ado.net_bai_03
Thuc hanh ado.net_bai_03
 
Semina Kết nối nguồn dữ liệu từ Internet
Semina Kết nối nguồn dữ liệu từ Internet Semina Kết nối nguồn dữ liệu từ Internet
Semina Kết nối nguồn dữ liệu từ Internet
 
Aspnet 3.5 _02
Aspnet 3.5 _02Aspnet 3.5 _02
Aspnet 3.5 _02
 
Lập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biếnLập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biến
 
Goi
GoiGoi
Goi
 
ChatMessenger
ChatMessengerChatMessenger
ChatMessenger
 
Dsd05 02b-json-rpca
Dsd05 02b-json-rpcaDsd05 02b-json-rpca
Dsd05 02b-json-rpca
 
Net06 asp.net applications & state management
Net06 asp.net applications & state managementNet06 asp.net applications & state management
Net06 asp.net applications & state management
 
Bai3 basic servlets_956
Bai3 basic servlets_956Bai3 basic servlets_956
Bai3 basic servlets_956
 
Data storage Android
Data storage AndroidData storage Android
Data storage Android
 
Report
ReportReport
Report
 
Asp.net 3.5 _7
Asp.net 3.5 _7Asp.net 3.5 _7
Asp.net 3.5 _7
 
Jniについて
JniについてJniについて
Jniについて
 
LinQ
LinQLinQ
LinQ
 
Bài 6: Working with DATA
Bài 6: Working with DATABài 6: Working with DATA
Bài 6: Working with DATA
 
Jquery
JqueryJquery
Jquery
 
7.databinding
7.databinding7.databinding
7.databinding
 
Ung dung web chuong 6
Ung dung web  chuong 6Ung dung web  chuong 6
Ung dung web chuong 6
 
ado.net
ado.netado.net
ado.net
 
MVC
MVCMVC
MVC
 

Android report

  • 1. TRUNG TÂM TIN HOC – ĐẠI HỌC KHOA HỌC TỰ NHIÊN – ĐẠI HỌC QUỐC GIA TP. HỒ CHÍ MINH Bộ Phận Lập Trình Di Động – Lập Trình Android Báo Cáo Tốt Nghiệp Khóa Lập Trình Android Cơ Bản Đề Tài: Học Viên:Nguyễn Xuân Dương Huỳnh Đức Vinh Lớp:Android tối 2,4,6 Giáo Viên:Bùi Quốc Ánh
  • 2. Nội Dung: I.Giới thiệu 1.Đề tài Chương trình sử dụng webservice lấy thông tin về tất cả thông tin động đất trên thế giới và show lên giao diện. 2.Phân tích và mô tả đề tài Đề tài sẽ thực hiện những yêu cầu sau: a.Xử lý: _Gửi requests lên service để lấy thông tin về động đất từ server về. _Xử lý thông tin lấy về (cắt những thông tin cần lấy bao gồm ngày, nơi, matitude ,latitude và longtitude) rồi lưu vào contentprovider. _Các thao tác lấy data và lưu data ở trên sẽ được thực hiện thông qua 1 service chạy ngầm. _Listview (main Activity)sẽ dùng để hiển thị thông tin động đất lên màn hình .Listview sẽ lấy dữ liệu từ content provider. b.Chức năng: _Khi click vào 1 row trên listview sẽ hiển thị thông tin chi tiết của trận động đất thông qua đối tượng dialog. _Khi click menu (option menu) sẽ có 2 chức năng là refresh và references .Refresh dung để load lại dữ liệu từ data lên listview .Chức năng reference dung để chọn chế độ update tự động hay không và thời gian update tự động là bao lâu đồng thời hổ trợ thêm 1 filter để lọc ra những trận động đất lớn hơn giá trị đưa vào. II.Thuật toán 1.Lấy dữ liệu từ server (dưới dạng XML): public void doRefreshEarthquakes() { try{
  • 3. URL url = new URL( "http://earthquake.usgs.gov/earthquakes/catalogs/1day-M2.5.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new InputSource(url.openStream())); doc.getDocumentElement().normalize(); NodeList nodeList = doc.getElementsByTagName("entry"); //Log.i("test",); /** Assign textview array lenght by arraylist size */ for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); Element fstElmnt = (Element) node; NodeList idList = fstElmnt.getElementsByTagName("georss:point"); Element idElement = (Element) idList.item(0); idList = idElement.getChildNodes(); String point=((Node)idList.item(0)).getNodeValue(); String[] location = point.split(" "); Location l = new Location("dummyGPS"); l.setLatitude(Double.parseDouble(location[0])); l.setLongitude(Double.parseDouble(location[1])); NodeList titleList = fstElmnt.getElementsByTagName("title"); Element titleElement = (Element) titleList.item(0); titleList = titleElement.getChildNodes(); String details=((Node) titleList.item(0)).getNodeValue(); String magnitudeString = details.split(" ")[1]; int end = magnitudeString.length()-1; double magnitude = Double.parseDouble(magnitudeString.substring(0, end)); details = details.split(",")[1].trim(); NodeList dateList = fstElmnt.getElementsByTagName("updated"); Element dateElement = (Element) dateList.item(0); dateList = dateElement.getChildNodes(); String dd=((Node)dateList.item(0)).getNodeValue(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM- dd'T'hh:mm:ss'Z'"); Date qdate = new GregorianCalendar(0,0,0).getTime(); try { qdate = sdf.parse(dd); } catch (ParseException e) { e.printStackTrace(); } NodeList linkList = fstElmnt.getElementsByTagName("link"); Element linkElement = (Element) linkList.item(0); linkList = linkElement.getChildNodes();
  • 4. String link1=linkElement.getAttribute("href"); Quake quake=new Quake(qdate, details, l,magnitude, link1); //lay 1 doi tuong moi ve addNewQuake(quake); } } catch (Exception e) { System.out.println("XML Pasing Excpetion = " + e); Log.i("test", "null pointer"); } } II.Thực hiện 1.Code chương trình a.Sơ đồ tổng quát Option Menu References ListView (Main Activity) (atoupdate và filter theo matitude) loadQuakesFromProvider() lọc thông qua reference bắn lên Intent Contentprovider Service lưu data
  • 5. Send get Qake Internet b.Code Ở đây sẽ trình bày theo từng lớp và sau đó là mối liên kết giữa chúng. b.1Các lớp _Quake class: là 1 đối tượng lưu các thông tin của 1 đối tượng Quake bao gồm: date(kiểu date time),longtitude(long),latitude(long),matitude(long), area(String). private Date date; private String details; private Location location; private double magnitude; private String link; _EarthQuake2011V1Activity class: là một main Activity dùng để hiển thị thông tin của Quakes lên màn hình. EarthQuake2011V1Activity _updateData() +Start service _updateFromReference() +Lấy các thông số lưu vào references trong lớp Reference để filter ,xử lý.
  • 6. _addQuakeToArray() +add 1 đối tượng quake vào earthquakes array. _loadQuakeFromProvider() +Lấy dữ liệu từ provider lên theo từng row rồi đổ vào đối tượng quake(1 row trong provider sẽ được lưu vào 1 quake )tiếp đó là add quake vào quakes array (thông qua hàm addQuakeToArray()) _EarthQuakeBroadCastReceiver class:lớp này này kế thừa từ BroadcastReceiver dùng để bắt lấy intent bắn lên từ sevice khi có 1 quakes mới được update. Ngoài các phương thức trên thì lớp này còn override lại 1 số phương thức của Activity để tạo option menu,và dialog. _EarthQuakeProvider class:lớp này kế thừa từ Contentprovider class dùng để tạo database và cung cấp 1 số phương thức để thao tác dữ liệu. // Column Names public static final String KEY_ID = "_id"; public static final String KEY_DATE = "date"; public static final String KEY_DETAILS = "details"; public static final String KEY_LOCATION_LAT = "latitude"; public static final String KEY_LOCATION_LNG = "longitude"; public static final String KEY_MAGNITUDE = "magnitude"; public static final String KEY_LINK = "link"; private static final String DATABASE_CREATE = "create table " + EARTHQUAKE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_DATE + " LONG, " + KEY_DETAILS + " TEXT, " + KEY_LOCATION_LAT + " FLOAT, " + KEY_LOCATION_LNG + " FLOAT, " + KEY_MAGNITUDE + " FLOAT, " + KEY_LINK + " TEXT);"; @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sort) { } @Override public Uri insert(Uri _uri, ContentValues _initialValues) { } @Override
  • 7. public int delete(Uri uri, String where, String[] whereArgs) { } @Override public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { } EarthQuakeService class:kế thừa từ lớp Sevice chạy ngầm gửi request và _ lấy data từ server.Sau đó lưu dữ liệu xuống provider. EarthQuakeService _refreshEarthquakes() +Start 1 new thread thực thi hàm bachgroundRefresh(). _backgroundRefresh() là 1 Runable +Override hàm void run() và thực thi phương thức doFreshEarthQuakes(). _TimerTask doRefresh() +Thực thi phương thức refreshEarthquakes() trong hàm run . _onStart() + Các hàm trên sẽ được sử dụng khi ta chọn chế độ auto update trong References.Nếu không update tự động thì sẽ gọi hàm doRefreshEarthQuake() _doRefreshEarthQuake(): +Sẽ thực hiện kết nối với server để lấy dữ liệu về sau khi lấy về sẽ đổ dữ liệu vào đối tượng Quake rồi add vào provider. _addNewQuake() +Hàm này dùng để add dữ liệu vào provider _announceNewQuake() +Hàm này sẽ được bắn lên nếu có 1 quake mới được lưu vào provider +Trong hàm này ta thực thi 1 status notification để khi có 1 quake mới được cập nhật thì status này sẽ bắn lên thông báo cho người dùng biết. 2.Giao diện a.Màn hình chính: sẽ hiển thị danh sách các earthquakes
  • 8.
  • 9.
  • 10. b.EarthQuake details:khi click vào 1 row trên listview sẽ hiển thị dialog để show details
  • 11. c.Option Menu: gồm 2 chức năng là refresh và reference.Refresh sẽ load lại data từ provider.Còn Reference thì sẽ set các chết độ auto update và filter theo matitude.
  • 12.
  • 14.
  • 15. *Màn hình sau khi filter với matitude bằng 5: