Quiero saber cómo configurar la hora de notificación. Deseo configurar notificaciones cada cinco minutos, , así que ayúdenme a hacer eso.Mostrar notificaciones de Android cada cinco minutos
public class FirstActivity extends Activity
{
private static final int HELLO_ID = 1;
//public static final int FLAG_AUTO_CANCEL = 0;`enter code here`
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.firstactivity);
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.statusbarnotification);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.text, "Hello, this message is in a custom expanded view");
notification.contentView = contentView;
notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(getApplicationContext(), SecondActivity.class);
//PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
mNotificationManager.notify(HELLO_ID, notification);
}
}
Gracias es un poco de lo que quería, pero tengo una pregunta para usted acerca de esto. ¿Cómo configuro 'AlarmManager' dentro de la clase de servicio para que cuando compruebe la base de datos y tenga algo nuevo para mostrar la notificación? (Si puede explicar en código sería mejor, no es necesario el código de la base de datos ... solo el AlarmManager dentro de la clase de servicio con la instrucción 'if') –
Cuando' StartAlarm() 'llamó ?? No recibo ninguna notificación ... el código no está funcionando g :( – Neo