Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The following is the code for setting up the alarm
- */
- //use alarm manager to time new event everyday
- Intent in = new Intent(application_context,ProfileChanger.class);
- PendingIntent pin = PendingIntent.getBroadcast(application_context, 0, in, 0);
- Calendar cal = Calendar.getInstance();
- String[] time = someEvent.getTime().split(":");
- cal.set(Calendar.HOUR, Integer.parseInt(time[0]));
- cal.set(Calendar.MINUTE, Integer.parseInt(time[1]));
- alarm.setRepeating(AlarmManager.ELAPSED_REALTIME,
- cal.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pin);
- /*
- Here's my class which responds when the alarm goes off
- It's in a class which extends BroadcastReciever, here's my onRecieve Method
- */
- public void onReceive(Context arg0, Intent arg1) {
- //This toast is never displayed
- Toast.makeText(arg0, "Hello World", Toast.LENGTH_LONG).show();
- arg0.getSystemService(Context.AUDIO_SERVICE);
- profileChanger = new Sound(am);
- String event_type;
- event_type = arg1.getStringExtra("event_type");
- if (event_type.equals("Lecture")){
- profileChanger.silent();
- }
- else if(event_type.equals("Tutorial")){
- profileChanger.vibrate();
- }
- else if(event_type.equals("Other")){
- profileChanger.vibrate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement