|
1 | 1 | package at.tacticaldevc.panictrigger;
|
2 | 2 |
|
| 3 | +import android.app.Notification; |
| 4 | +import android.app.PendingIntent; |
3 | 5 | import android.content.BroadcastReceiver;
|
4 | 6 | import android.content.Context;
|
5 | 7 | import android.content.Intent;
|
|
8 | 10 | import android.media.RingtoneManager;
|
9 | 11 | import android.net.Uri;
|
10 | 12 | import android.provider.Telephony;
|
| 13 | +import android.support.v4.app.NotificationCompat; |
11 | 14 | import android.telephony.SmsMessage;
|
12 |
| -import android.widget.Toast; |
13 | 15 |
|
14 | 16 | import java.io.IOException;
|
15 | 17 | import java.util.HashSet;
|
@@ -38,19 +40,25 @@ public void onReceive(Context context, Intent intent) {
|
38 | 40 | private void triggerAlarm(Context context, String address) {
|
39 | 41 | AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
|
40 | 42 | MediaPlayer mp = new MediaPlayer();
|
| 43 | + Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + address)); |
41 | 44 |
|
42 | 45 | audioManager.setStreamVolume(AudioManager.STREAM_ALARM, audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0);
|
43 | 46 | try {
|
44 | 47 | mp.setDataSource(context, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM));
|
45 | 48 | mp.setLooping(true);
|
46 | 49 | mp.prepare();
|
| 50 | + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "") |
| 51 | + .setContentTitle("!!! PANIC !!!") |
| 52 | + .setContentText(address + "triggered alarm! Calling in 1 minute!") |
| 53 | + .setPriority(NotificationCompat.PRIORITY_MAX); |
| 54 | + //.setContentIntent(PendingIntent.getBroadcast(context, 0, callIntent, 0)); |
47 | 55 | mp.start();
|
48 | 56 | TimeUnit.MINUTES.sleep(1);
|
49 | 57 | } catch (IOException | InterruptedException e) {
|
50 | 58 | e.printStackTrace();
|
51 | 59 | }
|
52 | 60 | mp.stop();
|
53 | 61 | mp.release();
|
54 |
| - context.startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + address))); |
| 62 | + context.startActivity(callIntent); |
55 | 63 | }
|
56 | 64 | }
|
0 commit comments