Android Smart Weather Alarm app development passed

Source: Internet
Author: User

The purpose of the development of this application is to produce a drop, and I rented a classmate every morning is riding a bike to work, so the mobile phone alarm clock will be a just fit for cycling up time points. However, one day in the morning after waking up to find out under a heavy rain, must not be able to go to work by bike, and then had to take the bus, but get up time just enough to ride the bus, rainy days and not good taxi ~ ~ so gorgeous li late ~ ~

Just I recently self-study Android development, and then think of doing such an alarm clock application, can be based on the weather conditions of the day to determine the time of the alarm clock, if it rains or snow, let it advance a point in time, such as half an hour trigger, so that the bike students have saved a lot of heart, Mom doesn't have to worry about me getting up late to work or going to school late.

Words do not say much, first look at the results (programmers do the interface, we understand. )

  

  

The following is the development process of the overall technical thinking and problems encountered:

1.android Alarm Set-up

Android Alarm settings Use the Android Alarmmanager system service, according to the user input alarm time to make the system alarm trigger settings. Because the user's input is relatively simple, so the user set the alarm time directly in the XML, easy to get at any time.

Define your own Alarm event broadcast receive class receiver when the alarm is triggered using this class for listening.

2. Urban positioning and weather conditions acquisition

To locate and get weather information, it was intended to take two steps to write the code of the city positioning, and then get to the city name and then go to an API to get the city's weather conditions, but the internet for a long time did not find a suitable access to weather conditions of the interface, really a sad result. Then one day found that the API interface of the hot map has a weather interface, can be one step to get the city and weather conditions, so this problem easily solved ...

3. Special weather alarm Clock advance setting

At this point to the application of the most important logical processing, how to make it according to the alarm day of the weather conditions automatically determine the time of the alarm clock??

My train of thought is this, when the user sets the alarm time, normally will give the system's Alarmmanager service registers a user to set the time point the alarm clock cycle triggers the service, But I changed it to set a loop that triggers the service in advance of the user's set time of half an hour (assuming the user wants half an hour ahead).

For example, the user set a 8:00 alarm clock, I will change it to 7:30, when 7:30 of my broadcast receiver class receiver received the system alarm triggered event, and then the interface mentioned in 2 to get the current real-time weather conditions, if it is raining snow and other special weather let the alarm clock at this moment, The alarm rang immediately. If it is normal weather to register a 8:00 single alarm event with the system, receiver will trigger the alarm immediately after receiving the event at 8:00 without the weather judgment.

At this point, the core function of the whole application is basically realized. I Android rookie, thinking and technology are no technical content, so the code is not on, if there is a wrong place to ask more advice.

Android Smart Weather Alarm app development passed

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.