Back to project page CSCI567---Workspace.
The source code is released under:
MIT License
If you think the Android project CSCI567---Workspace 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 csci567.alarmexample; /* w w w. j a va2s. co m*/ import android.os.Bundle; import android.app.Activity; import android.util.Log; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends Activity { SampleAlarmReceiver alarm = new SampleAlarmReceiver(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } // Menu options to set and cancel the alarm. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // When the user clicks START ALARM, set the alarm. case R.id.start_action: Log.d("CSCI567","Starting Alarm"); alarm.setAlarm(this); return true; // When the user clicks CANCEL ALARM, cancel the alarm. case R.id.cancel_action: alarm.cancelAlarm(this); return true; } return false; } }