How can i to run a method check() in every five minutes? I want to check every five minutes have we new data or not, if is new data, then show notification
methods:
private void startAlarm() {
    AlarmManager alarmManager = (AlarmManager) this.getSystemService(this.ALARM_SERVICE);
    long when = System.currentTimeMillis();         // notification time
    Intent intent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
    alarmManager.setRepeating(AlarmManager.RTC, when, AlarmManager.INTERVAL_FIFTEEN_MINUTES), pendingIntent);
}
public boolean isOnline(){
      ConnectivityManager cm = (ConnectivityManager)
        getSystemService(CONNECTIVITY_SERVICE);
      NetworkInfo netinfo = cm.getActiveNetworkInfo();
      if(netinfo ==null || !netinfo.isConnectedOrConnecting())
          return false;
      return true;
}
public void check(){
    if(isOnline())
    {
        //show notification if we have new data
    }
}
