So basically I am building an app that will display events on a screen and update it as soon as a specific time which has been set has been reached. It would be easier to use a timer instead of Cloud Functions to achieve this but when I tried, it just didn't work. Looked at other questions on StackOverFlow but all weren't clear. What am I doing wrong? Below is my code.
update_btn.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
    int time = 0;
    String info = information.getEditText().getText().toString();
    final long timeCountInMilliSeconds = time * 60 * 1000;
    time = Integer.parseInt(xxx.getEditText().getText().toString().trim());
    if (!TextUtils.isEmpty(info) && !TextUtils.isEmpty(String.valueOf(time))) {
        progressBar.setVisibility(View.VISIBLE);
        update_ref = FirebaseDatabase.getInstance().getReference().child("Event Halls").child("Ankobra One").child("Event Schedule");
        final int finalTime = time;
        update_ref.setValue(info).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                final DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("Event Halls").child("Ankobra One").child("Event Schedule");
                ref.addListenerForSingleValueEvent(new ValueEventListener() {
                    void onDataChanged(@NonNull DataSnapshot snapshot) {
                        new android.os.Handler().postDelayed(
                                new Runnable() {
                                    public void run() {
                                        retrieve_ref.setValue("No event scheduled");
                                    }
                                },
                                timeCountInMilliSeconds);
                    }
                    @Override
                    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                    }
                    @Override
                    public void onCancelled(@NonNull DatabaseError databaseError) {
                    }
                });
                        Toast.makeText(AnkobraOneActivity.this, "Event Changed and scheduled for " + finalTime + " hours", Toast.LENGTH_LONG).show();
                        progressBar.setVisibility(View.INVISIBLE);
                        myDialog.dismiss();
                    }
                });
            } else
            {
                Toast.makeText(AnkobraOneActivity.this, "Insert all details accordingly", Toast.LENGTH_SHORT).show();
            }
        }
    });
I used this answer to achieve what I have done so far but it didn't work.
Help?
 
     
    