0
What I need is a hint, help to know how to implement an Alarmmanager that whenever a notification appears something like this
In the Home screen of the phone and is making a sound every 5s
for the notification I have the following code
protected void criarNotificacao(Context context, MensagemAlerta messagesAlerts, Class<?> activity) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notificaction = new Notification(R.drawable.ic_launcher,
messagesAlerts.getTitle(), System.currentTimeMillis());
notificaction.sound = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "6");
notificaction.flags |= Notification.FLAG_INSISTENT;
notificaction.flags |= Notification.FLAG_AUTO_CANCEL;
PendingIntent p = PendingIntent.getActivity(this, 0,
new Intent(this.getApplicationContext(), MyActivity.class), 0);
notificaction.setLatestEventInfo(this, messagesAlerts.getSubTitle(),
messagesAlerts.getBody(), p);
notificaction.vibrate = new long[] { 100, 1000, 1000, 1000 };
notificationManager.notify(R.string.app_name, notificaction);
}
The other class
public class MensagemAlerta {
private CharSequence title;
private CharSequence body;
private CharSequence subTitle;
public MensagemAlerta(CharSequence title, CharSequence body,
CharSequence subTitle) {
this.title = title;
this.body = body;
this.subTitle = subTitle;
}
public CharSequence getTitle() {
return title;
}
public void setTitle(CharSequence title) {
this.title = title;
}
public CharSequence getBody() {
return body;
}
public void setBody(CharSequence body) {
this.body = body;
}
public CharSequence getSubTitle() {
return subTitle;
}
public void setSubTitle(CharSequence subTitle) {
this.subTitle = subTitle;
}}
NOTE: I call this function from within a Thread
What’s the matter?
– ramaral
I need to implement an Alarmmanager call with a screen like the one I reported and vibrate, playing a 5 in 5s sound
– Guilherme