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
On Aug 31, 4:48 pm, parag <[email protected]> wrote:
> check this out
>
> http://justcallmebrian.com/?p=129
>
> its a very useful sample
>
> On Aug 31, 12:55 pm, Mark Murphy <[email protected]> wrote:
>
> > Use AlarmManager.
>
> > On Tue, Aug 31, 2010 at 2:02 AM,chetan<[email protected]> wrote:
> > > 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
> > >ChetanChauhan
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Mark Murphy (a Commons
> > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Development Wiki:http://wiki.andmob.org-Hide quoted text -
>
> > - Show quoted text -
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en