Android's alarm clock and Management

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

分类:Mobile 时间:2010-06-21 人气:235
blog comments powered by Disqus


  • Android mobile development environment to build self- 2010-10-16

    These days at the beginning of android mobile development, bought the android with the practice started, just read a few chapters, is to build android development environment and build process, I talk about the problems: Need software eclipse, androi

  • C # Forms MessageBox display disappear (mobile development Pocket PC 2003) 2010-05-07

    MessageBox boxes usually have to manually shut down the information for the simple tips, every time we still have to turn off a lot of trouble. I think of how to make MessageBox display turns off automatically after a period of time. While that is de

  • android mobile development developer simple examples 2010-10-16

    Oh is finally written a two page jump actity, feeling you can, Oh well, here this evening to record my android instance: Development Environment: windowXP, androidSDK2.2, eclipse3.4 (on the environment configuration see my other blog post description

  • Mobile Web2.0: Ajax in the areas of mobile development 2010-11-19

    Transfer from First, the concerns: This article describes some of the views expressed in my former, while also adding some new text view. This article focuses on mobile development in Ajax's inf

  • Analysis of major mobile development 2010-12-16

    Very sorry chapter to give back to the analysis of mobile development is not very specific and accurate know whether the full paper. But I know I say that the sunshineparasol wrote to see the present, android hot, worked for 3 years, I would also lik

  • Summary 4 Android mobile development TIPS 2011-05-22

    A good example of a handler public static final int UPDATE_DATA = 0; / / constant update data on behalf of public static final int UPDATE_COMPLETED = 1; / / constant update data on behalf of TextView tv; / / TextView object reference Button btnStart;

  • android mobile development package download the source code case 2010-05-26

    android mobile development package download the source code case

  • Mobile development experience 2010-06-17

    me the mobile development, with not only thinking, not only function to achieve more of a debugging process and thin. se and ee would be very difficult to switch to the estimate used, and why? Need to understand some of ME. 20% of the time in the pla

  • Mobile Development Imperative 2010-09-27

    Mobile Development Imperative

  • Ranking from the Objective-C to see the vigor of mobile development 2010-12-13

    For most people, Objective-C is strange, because it's popular process is too short. But through the Objective-C's hot, we can understand Apple's App Store application Why the easy to break a hundred thousand. The popular process of Objective-C Top TI

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.351 (s). 10 q(s)