Android earthquake (seismic display) project detailed

Source: Internet
Author: User
Tags date xmlns

Environment: Android Studio 0.5.2, gradle 1.11, Kindle Fire

Time: 2014-3-24

Fixed location Information exception: http://blog.csdn.net/caroline_wendy/article/details/24465487

The earthquake project, mainly reads the Survey (subscription source) provided by the USGS (United States Geological feeds, the United States Bureau of Exploration) for displaying data;

Need to read the data on the Internet, format resolution (parse), the data type is atom type, similar to XML.

Subscription Source Address: Http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.atom

Format:

<feed xmlns= "Http://www.w3.org/2005/Atom" xmlns:georss= "Http://www.georss.org/georss" > <title>usgs Magnitude 2.5+ earthquakes, past day</title> <updated>2014-03-24T07:56:39Z</updated> <author > <name>u.s. Geological survey</name> <uri>http://earthquake.usgs.gov/</uri> </author > <id> http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.atom </id> <link rel= "se LF "href=" Http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.atom "/> <icon>http:// Earthquake.usgs.gov/favicon.ico</icon> <entry> <id>urn:earthquake-usgs-gov:ci:15479569</id > <title>m 2.9-9km W of Alberto Oviedo Mota, mexico</title> &LT;UPDATED&GT;2014-03-24T07:48:34.609Z&L t;/updated> <link rel= "Alternate type=" text/html "href=" http://earthquake.usgs.gov/earthquakes/eventpage/ ci15479569 "/> <summary type=" html > <! [cdata[;p class= "quicksummary" ><a href= "Http://earthquake.usgs.gov/earthquakes/eventpage/ci15479569#dyfi" Mmi-i "title=" Did you Feel It? Maximum reported intensity (0 reports) ">dyfi?" -<strong class= "Roman" >I</strong></a></p><dl><dt>Time</dt><dd> 2014-03-24 07:38:10 utc</dd><dd>2014-03-23 23:38:10-08:00 at epicenter</dd><dt>location< /dt><dd>32.222°n 115.274°w</dd><dt>depth</dt><dd>14.10 km (8.76 mi) </dd> </dl>]]> </summary> <georss:point>32.2215-115.274</georss:point> <georss:elev>- 14100</georss:elev> <category label= "age" term= "past Hour"/> <category label= "Magnitude" term= "Magnitu" De 2 "/> </entry> ... .....

Specific design of earthquake:

New project: Earthquake

1. New Quake (Quake.java) class, display seismic data.

Location: Java->package->quake

Package Mzx.spike.earthquake.app;  
      
Import android.location.Location;  
Import Java.text.SimpleDateFormat;  
      
Import Java.util.Date;  
    public class Quake {private date date;  
    Private String details;  
    Private Location Location;  
    private double magnitude;  
      
    Private String link;  
    Public Date getDate () {return date;}  
    Public String Getdetails () {return details;}  
    Public Location getLocation () {return Location;}  
    Public double Getmagnitude () {return magnitude;}  
      
    Public String GetLink () {return link;}  
        Public Quake (Date _d, string _det, Location _loc, double _mag, string _link) {date = _d;  
        Details = _det;  
        location = _loc;  
        magnitude = _mag;  
    link = _link;  
        @Override public String toString () {SimpleDateFormat SDF = new SimpleDateFormat ("hh.mm");  
        String datestring = Sdf.format (date); Return DAtestring + ":" + magnitude + "" + details; }  
      
}

Detailed

1. Types of display: date, dates; Details, detailed information, location; location, position; magnitude, magnitude; link, links;

2. Get () method, return information; constructor function, assigning initial value; ToString (), default output information;

2. Modify activity_main.xml and add fragment.

Location: Res->layout->activity_main.xml

<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"
    xmlns:tools= "http:// Schemas.android.com/tools "
    android:layout_width=" match_parent "
    android:layout_height=" Match_parent "
    android:paddingleft= "@dimen/activity_horizontal_margin"
    android:paddingright= "@dimen/activity_ Horizontal_margin "
    android:paddingtop=" @dimen/activity_vertical_margin "
    android:paddingbottom=" @dimen Activity_vertical_margin "
    tools:context=" mzx.spike.earthquake.app.MainActivity ">  
      
    <fragment Android:name= "Mzx.spike.earthquake.app.EarthquakeListFragment"
        android:id= "@+id/earthquakelistfragment"
        android:layout_width= "match_parent"
        android:layout_height= "match_parent"
     />  
</ Relativelayout>

Add fragment to specify the implementation (. java) file location.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.