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. Excluding test files from the compiled Android app

Hi Gustav:

I'd recommend creating a second Android app project that contains your
tests, and add the original app project to the test project's build path.
As an example, lets say your existing app is called "Foo". Do the following

1. Create a new Android Project called "FooTest".
      - Uncheck the "Create Activity" checkbox as it won't be needed
      - Make sure you choose a unique package name for "FooTest", that is
different than "Foo"'s package
2. Add the "Foo" project to the "FooTest" project's build path. This can be
done via the following steps:
     a. Select the "FooTest" project from the Eclipse Package Explorer
     b. Select *File > Properties*
     c. Select *Java Build Path*
     d. Select *Projects*
*     *e. Select *Add*
     f. Select "Foo" project

Now move your tests into "FooTest". You should be able to run the tests that
do not reference any Android classes as a "JUnit test". Make sure you select
the "Android JUnit Test Launcher" when prompted.

If you decide later on you want to add tests that do refer to Android
specific classes, Steve's suggestion is a good one - take a look at ApiDemos
and the ApiDemos tests. You'll want to ensure the following items are added
to the test's AndroidManifest.xml:

*<application>* **

*   <uses-library android:name="android.test.runner" />*




 android:targetPackage="com.foo" <!-- this should be set to package
name of "Foo" project -->

 android:label="Tests for Foo"/>


You can run tests on an Android target by running the tests as a "Android
JUnit Test". But note JUnit4 tests are currently not supported on the
Android platform.

I hope that helps. Please let me know if you need any clarification.



2. Rooting ADP1 holiday edition

I got an ADP1 but not from google (from ebay) and I think it is
holiday edition that was with a google employee. when I got it, it was
on version 1.1. In my first day with it, it notified me that an
upgrade to 1.5 is available and it downloaded and installed it.
Now, I found myself don't have root on terminal. when executing "adb -
d root" I get message "adbd cannot run as root in production builds".
and also I can not access paid applications in the android market!
I don't know if my phone now is a developer phone or a normal phone?!!

Settings -> About Phone reports this
Model number: Android Dev Phone 1
Firmware version: 1.5
Kernel Version: 2.6.27-00393-g6607056     s...@sandroid #1
Build number: CRB43

how can I have root permissions on shell? have I to re-flash the
phone? if yes, what image should I use? will I lose my installed apps
and my configurations I did on the phone?

thanks in advance.

3. Android1.5

4. another AppWidget issue: can't start parent app, "process is bad"

5. Media player problem : got the error (1,-15)

6. How can I gray out a toggle button?

7. Invoking Java function via c