-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAlarmReceiver.java
More file actions
43 lines (37 loc) · 1.62 KB
/
AlarmReceiver.java
File metadata and controls
43 lines (37 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.example.abcd.alarmclock;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.content.WakefulBroadcastReceiver;
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
//this will update the UI with message
/*Intent i = new Intent(context,AlarmActivity.class);
context.startActivity(i);*/
/* AlarmActivity inst = AlarmActivity.instance();
inst.setAlarmText("It's a time to move on!");
*/
//this will sound the alarm tone
//this will sound the alarm once, if you wish to
//raise alarm in loop continuously then use MediaPlayer and setLooping(true)
/* Uri alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
if (alarmUri == null) {
alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
}
Ringtone ringtone = RingtoneManager.getRingtone(context, alarmUri);
ringtone.play();*/
//this will send a notification message
/* ComponentName comp = new ComponentName(context.getPackageName(),
AlarmService.class.getName());
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);*/
intent.putExtra("key",1);
context.startService(new Intent(context, AlarmService.class));
}
}