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.

Thanks
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

 http://justcallmebrian.com/?p=129 

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";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btn=(Button)findViewById(R.id.Button01);
        btn.setOnClickListener(this);
    }

        @Override
        public void onClick(View v) {
                // TODO Auto-generated method stub
                 Log.d(TAG,"OnCLick Set tne time 1");
                if(v.getId()==R.id.Button01)
                {
                        /*Set the Timer*/
                     Log.d(TAG,"OnCLick Set tne time");
                         Calendar cal = Calendar.getInstance();
                         cal.clear();
                         cal.add(Calendar.MINUTE,7);


                         Intent intent = new Intent(this, 
AlarmReceiverTest.class);
                         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) 
getSystemService(ALARM_SERVICE);
                         am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 
sender);



                }
        }
}


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

Thanks
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 buy a HTC G1 (Dream) Phone?

Is there any source to buy one of these phones at this time?  I want
to make sure our titles look their best on the handset when it ships.

Thank you,

William Volk

--~--~---------~--~----~------------~-------~--~----~

2. Extremely new, need help to install on Eclipse

I just got done installing java 6, eclipse 3.3 and android sdk .9 on
Ubuntu.  I got eclipse with java working but I cannot seem to get
Android working with Eclipse.  When I do the basic tutorial (the one
where it just says "Hello, Android", it just pops up the Emulator
(looks a lot like the HTC Dream) and says Android in the black
screen.  Any help would be appreciated.

--~--~---------~--~----~------------~-------~--~----~

3. First Steps: Learning Java by programming Android applications?

4. ViewVideo & mp4 or 3gp (both local or net) problems

5. :Button

6. : Button

7. TextView weird layout