Ola estou criando uma app simples que recebe uma notificação toda vez que eu clico num botão do meu layout, ate aqui tudo funciona perfeitamente. Agora quero que essa notificação fique repetindo por exemplo a cada minuto mesmo com a app fechada ate eu desactivar a mesma. Alguém pode me dar uma dica de como posso fazer isso?? :).
Aqui está o meu código de inicio.
public class MainActivity extends Activity {
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
Button createNotification = (Button) findViewById
(R.id.create_notification_button);
createNotification.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent (MainActivity.this ,
notificationActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity
(MainActivity.this, 0, intent, 0);
Notification notification = new Notification.Builder (MainActivity.this)
.setContentTitle(getString(R.string.new_notification))
.setContentText(getString (R.string.notification_content))
.setSmallIcon (R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.getNotification();
notification.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager =
(NotificationManager) getSystemService (NOTIFICATION_SERVICE);
notificationManager.notify (0, notification);
}
});
}
}