--Embedded software development
Name |
Function module |
Number of lines of code |
Note |
谢灿辉 |
widget |
200 |
Desktop applet |
Li Yangmin |
GPS location, Baidu map API |
100-150 |
Get your current City |
Dingxiaofang |
City Selection Activity , the weather API Get the weather |
100-200 |
including database interaction |
The software is a weather class application software, with widgets, start the software can be located in the city or manually set up after the implementation of weather query, PM2.5 query, 7 days temperature curve, we can show from the pictures and text of the last week's weather forecast and related warm tips.
The data is provided through a background service, which is acquired and stored in the database at a certain time interval through the API.
From the above can be seen the main features of this software are:
① launch the app widget app;
② set the interface, set the city to display the weather forecast;
③ detailed interface, through the picture text display the current week's weather forecast, warm hint and temperature curve change;
④ display interface, through the picture text display time, temperature and so on;
④ Sharing Interface
System Design
- Module
1. Display of weather forecasts
In order to make the user's experience more convenient, we set the software as a small plug-in on the main face of the phone, the data used to display on the desktop. In the user interface, the (appwidget) Framework is used to provide intuitive interactive operations.
Weather Widget Development steps:
① Layout of design widgets
Res/layout/widget.xml Res/drawable/widget_background.xml
The first step in creating a wiget is to design and implement the Wiget component layout, which is the interface between widgets and user interaction. Widgets are very similar to the layout design and implementation of the activity, which is the layout resource file of XML in the/res/layout directory.
② defining metadata for widgets
Widget metadata file saved in/res/xml/weather_widget_4x2.xml
③ Implement widget Additions, deletions, updates
the process of adding, deleting and updating widgets is implemented mainly through Appwidgetprovider class, the class itself inherits Broadcastreceiver, which is used to receive updates, deletions, and effective messages related to widgets. When appwidgetprovider receives these messages, the corresponding event handlers are called separately.
description
event |
calling function | TD style= "PADDING-LEFT:7PX; padding-right:7px; Border-top:solid 0.5pt; Border-left:none; Border-bottom:solid 0.5pt; Border-right:solid 0.5pt ">
action_ Appwidget_update |
onupdate ( ) |
widget update |
action_ appwidget_deleted |
ondelete ( ) |
widget delete |
action_ appwidget_enabled |
onenabled () |
widget effective |
Action_appwidget_disabled |
Ondisabled () |
Widgets Failure |
④ declaring widgets in the Androidmanifest.xml file
/androidmanifest.xml
For the widget to take effect it is also required to be declared in the Androidmanifest.xml file, which is primarily stated in the file Appwidgetprovider class
- data interaction
1. Use API to get weather data, data get address: http://sixweather.3gpk.net/ sixweather.aspx?city=%e5%b9%bf%e5%b7%9e
Get the key code for the weather:
com.yz.util/getweathertask.java
Send an HTTP GET request to the weather interface
server returns an XML document containing weather content
- Custom Positioning City
Code: Request Location permission
Baidu Map API
- User interaction
Set up city (database read process)
Com.yz.app
Com.yz.db
- System Management
1. Page implementation Layout Management
According to requirements analysis, the application should contain four main user interfaces. The display interface should contain information such as City, temperature and time, and the detailed interface contains three interfaces, namely, the weather center, warm cue and temperature curve, which includes the current and the following six days of weather forecast, temperature trend and other information; Set the interface, mainly for the user to manually query the city weather forecast The sharing interface provides the ability to share the weather forecast information.
Picture:
Span style= "color:red; Font-size:7pt ">/res/layout/activit_weather_center.xml
sharing channel/assets/platforms.xml
2. Background service (update on Wake-up device)
- Database design and implementation (manually specified location situation)
City.db-> get weather API for City-weather
Six, the program module design
From this functional requirement we have divided the entire program into four functional modules:
① program Startup
② user Interface
③ Backstage Service
④ Database Adapter
Android Weather Design