I'm creating a app Simple receiving a notification every time I click a button of my layout , everything works perfectly. Now I want this notification be repeated for example every minute until I disable it. Can anyone give me a hint how can i do this ?? :).
Here is my code.
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);
}
});
}
}