iOS app Development Simple example

Source: Internet
Author: User

This time the task is two people to design a simple app, which design to the source code design, source code implementation and source code control. Before we designed the app, we looked at how the software was designed and implemented, and then we decided to make a simple app-reminder of the small alarm clock. In the design process, a lot of problems, because never designed the app, began to completely do not know how to design code, we two discussed under, in Baidu found a tutorial, followed by a tutorial step after study how to design an app. We think to make a reminder small alarm clock app, its function is the user set up the time and things, the app will be set by the user time, and then show the user before the input.

Code we refer to some information and other design code, the final core code is as follows

Package com.example.alarmtest;

Import Java.util.Calendar;

Import android.app.Activity;
Import Android.app.AlarmManager;
Import android.app.PendingIntent;
Import Android.app.Service;
Import Android.app.TimePickerDialog;
Import android.content.Intent;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Android.widget.Button;
Import Android.widget.TimePicker;
Import Android.widget.Toast;

public class Mainactivity extends Activity {
Button button;
Alarmmanager Alarmmanager;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Button = (button) Findviewbyid (R.id.button1);

Get Alarmmanager Object
Alarmmanager = (Alarmmanager) getsystemservice (Service.alarm_service);

Button.setonclicklistener (New Onclicklistener () {

@Override
public void OnClick (View arg0) {
Calendar currenttime = Calendar.getinstance ();
Creates a Timepickerdialog instance and displays
New Timepickerdialog (mainactivity.this, 0,
New Timepickerdialog.ontimesetlistener () {

@Override
public void Ontimeset (timepicker view, int hourofday, int minute) {
Specifying the start Alarmactivity component
Intent Intent = new Intent (mainactivity.this, Alarmactivity.class);
Create a Pendingintent object
/*
* The difference between pendingintent and intent is that pendingintent deal with what is about to happen.
* For example: in the Notification bar notification jump page, not immediately jump
* Examples of pendingintent are usually obtained through getactivity, Getbroadcast, GetService
*
*/
pendingintent pi = pendingintent.getactivity (mainactivity.this, 0, intent, 0);
Calendar C = calendar.getinstance ();
C.settimeinmillis (System.currenttimemillis ());
C.set (Calendar.hour, hourofday);
C.set (Calendar.minute, MINUTE);

Alarmmanager.set (Alarmmanager.rtc_wakeup, C.gettimeinmillis (), pi);
Toast.maketext (Mainactivity.this, "Set alarm success", Toast.length_short). Show ();
}
}, Currenttime.get (Calendar.hour_of_day), Currenttime.get (Calendar.minute), false). Show ();
}
});
}
}

iOS app Development Simple example

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.