Currently what I am doing is,When the user registers on the app a unique number is getting generated and this code is saved in Firebase and in invitation text I am using this code to invite other users to join my circle .
Date myDate = new Date();
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a", Locale.getDefault());
String date = format1.format(myDate);
Random r = new Random();
int n = 100000 + r.nextInt(900000);
String code = String.valueOf(n);
on clicking register button this 'code' is getting saved to firebase.
now i want to make an expiry period for this code.That is I need to create a new random number every 5dyas. How to accomplish this.This is my first app.Please help me.
below I am showing the invitation activity code
else if (id == R.id.inviteMembers) {
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String code=dataSnapshot.child(uid).child("code").getValue(String.class);
Intent myIntent = new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
myIntent.putExtra(Intent.EXTRA_TEXT,"Hi join my Circle to share location.My Circle Code is"+code);
startActivity(myIntent.createChooser(myIntent,"Share Using: "));
locreference.child("online").setValue("true");
}
Aucun commentaire:
Enregistrer un commentaire