Timer in an App

by chetan » Tue, 31 Aug 2010 14:03:09 GMT

Sponsored Links
 Hi All,
           I am creating an App in which i need to add a timer for
postpone the one event for 1 hr and start same event after 1 hr , so i
want to know how i can implement the same. Are there any Timer api's
and handling of them in android.

Chetan Chauhan


Timer in an App

by Mark Murphy » Tue, 31 Aug 2010 15:56:01 GMT

 Use AlarmManager.


Sponsored Links

Timer in an App

by parag » Tue, 31 Aug 2010 19:49:14 GMT

 check this out


its a very useful sample

> >

Timer in an App

by chetan » Thu, 09 Sep 2010 12:32:30 GMT

 Hi ,
        I have created an app with using Alarm Manager and added the 7
min alarm. Find the code below.

package com.example.ReminderTest;

import java.util.Calendar;

public class ReminderTest extends Activity implements OnClickListener{
    /** Called when the activity is first created. */
        private String TAG="ReminderTest";
    public void onCreate(Bundle savedInstanceState) {
        Button btn=(Button)findViewById(R.id.Button01);

        public void onClick(View v) {
                // TODO Auto-generated method stub
                 Log.d(TAG,"OnCLick Set tne time 1");
                        /*Set the Timer*/
                     Log.d(TAG,"OnCLick Set tne time");
                         Calendar cal = Calendar.getInstance();

                         Intent intent = new Intent(this, 
                         intent.putExtra("alarm_message", "O'Doyle Rules!");
                         // In reality, you would want to have a static 
variable for the
request code instead of 192837
                         PendingIntent sender = 
PendingIntent.getBroadcast(this, 192837,
intent, PendingIntent.FLAG_UPDATE_CURRENT);

                         // Get the AlarmManager service
                         AlarmManager am = (AlarmManager) 
                         am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 


Now my question ,  would the set alarm  persist after reboot of
phone ?

Chetan Chauhan

> > >

Timer in an App

by Kostya Vasilyev » Thu, 09 Sep 2010 15:23:52 GMT

 09.09.2010 8:32, chetan :
Now my question , would the set alarm persist after reboot of phone ? Thanks Chetan Chauhan
No, it won't. The way handle it is to implement code to receive BOOT_COMPLETED broadcast, and start the alarm (and perhaps the service) then. -- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com --

Other Threads

1. How to change text in a XML-defined text view

Lets say i define in the layout.main a text view but i want to change the
text during the execution of the application. How can i 'call' the view in
the code? Im guessing i can use R.java but i dont know how... Any ideas? An
example would be really cool...



Hugo Rafael Augusto


2. Problem while compiling the cupcake Android release for the HTC G1 dev edition

This question is more suited for the android platform forum

Balwinder Kaur
Open Source Development Center
T  Mobile stick together

The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.


3. AsyncTask - wait until the task has finished

4. Accessing the CallLog from a Service or Broadcastreceiver

5. Question on WebView.addJavaScriptInterface()

6. how to extract RAW HTML using WebView

7. How to use other app to 'view' the media in Gallery