1

I am working with Firebase again. Inside my app I have a button which if the user clicks it shows an advert to them and at the same time it adds a boolean called Promoted to firebase which = true along with a time stamp. How can Ii use the timestamp value to check that a user only gets 1hr before the boolean Promoted changes to false?

  if (mRewardedAd != null) {
        Activity activityContext = getActivity();
        mRewardedAd.show(activityContext, new OnUserEarnedRewardListener() {
            @Override
            public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                // Handle the reward.
                Log.d("TAG", "The user earned the reward.");
               
                btn_free_promo.setVisibility(View.GONE);
 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String currentDateTime = dateFormat.format(new Date()); // Find todays date
    Date date = (Date) dateFormat.parse(currentDateTime);
    long output = date.getTime() / 1000L;
    String str = Long.toString(output);

    long timestamp = Long.parseLong(str) * 1000;
    PROMOTED = true

     Map<String, Object> map = new HashMap<>();
     map.put("timestamp", timestamp);
        map.put("PROMOTED", PROMOTED);

                 DatabaseReference mixRef = reference.child("MIXES");
        mixRef.child(title).setValue(map);
halfer
  • 19,824
  • 17
  • 99
  • 186
markharrop
  • 866
  • 1
  • 9
  • 30

0 Answers0