Android's alarm clock and Management

sponsored links

android alarm clock

Mobile Development 2009-08-19 09:42:41 read 194 comments 0 font size: large, medium

Android recently looked at the alarm clock and Management (AlarmManager), I really do not mistake, powerful and simple, the code is as follows:

1, a AlarmReceiver inherited into BroadcastReceiver, and AndroidManifest.xml statement
public static class AlarmReceiver extends BroadcastReceiver (
@ Override
public void onReceive (Context context, Intent intent) (
Toast.makeText (context, "Alarm prompts: Time to!", Toast.LENGTH_LONG). Show ();

2, the establishment of Intent and PendingIntent, to call the target component.
Intent intent = new Intent (this, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast (this, 0, intent, 0);

3, set the alarm clock management for instance:
AlarmManager alarmManager = (AlarmManager) getSystemService (Context.ALARM_SERVICE);
Set single-alarm clock:
alarmManager.set (AlarmManager.RTC_WAKEUP, System.currentTimeMillis () + (5 * 1000), pendingIntent);
Set the alarm clock cycles:
alarmManager.setRepeating (AlarmManager.RTC_WAKEUP, System.currentTimeMillis () + (10 * 1000), (24 * 60 * 60 * 1000), pendingIntent);

Done! Of course, dealing here only with the response alarm text, you can play sounds, or have a system with more complex notification, where you are God, and everything you do
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Android's alarm clock and Management

  • Hibernate access picture sample

    General web users to upload picture at treatment would normally uses two types of strategies: First, put directly into the picture in the database Blob field; II database are stored only at the picture on the path of the server information?, Pictures stor

  • hibernate query cache

    hibernate query cache Query cache is cached result set of common property On the entity object cache only the result set id Query cache life cycle, when the associated table happened to amend, then the query cache of the life cycle of The End Query cache

  • Struts Spring Hibernate test Noodles

    Hibernate working principle and why to use? Principle: 1. To read and parse configuration file 2. Read and analytic mapping information, create a SessionFactory 3. Open Sesssion 4. Create Affairs transation 5. Persistence operation 6. Submitted Services 7

  • hibernate how to store binary, image and other major fields.

    model categories: reportByte binary type for the database fields. public class PfReportStyle implements , Cloneable { // Fields /** * */ private static final long serialVersionUID = 1L; private Long id; private byte[] reportByte; // C

  • js examples of common events

    <html> <head> <script type="text/javascript"> / / Which mouse button is clicked function whichButton1 (event) ( if (event.button == 2) ( alert ( "You clicked the right mouse button!") ) else ( alert ( "You c ...

  • SUI-JavaScript rich UI library integration solution

    Introduction: SUI is not a class implementation of the UI, nor is it a standard set of UI markup language, it is just to help the existing UI frameworks (such as Ext, YUI like) to mark the way to the statement and the creation of UI. The names of these ta

  • hibernate study of the second

    Persistence of three main points: 1, a statement for persistent fields accessors (accessors) and whether the variable signs (mutators) Property statement is not necessarily required for the public's. Hibernate can be default, protected or private ...

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • hibernate generic generic DAO

    package org.lzpeng.dao; import; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries