Back to project page Le-Mouv.
The source code is released under:
MIT License
If you think the Android project Le-Mouv listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ar.listenmouv; //from w w w .ja va 2s . c om import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; import java.util.Calendar; /** * Created by ariviere on 19/11/2013. */ public class AlarmActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.alarm); // launchAlarm(); } private void launchAlarm(){ //Create an offset from the current time in which the alarm will go off. Calendar cal = Calendar.getInstance(); cal.add(Calendar.SECOND, 5); //Create a new PendingIntent and add it to the AlarmManager Intent intent = new Intent(this, MainActivity.class); intent.putExtra("alarm", true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 12345, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager)getSystemService(Activity.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent); } }