samedi 19 octobre 2019

Boolean balue changed but not recognized by if statement

I'm new to Android Studio and I have following problem.

I have two classes, "class1" and "class2". When I initialize a boolean called "test" (true) in "class1" and ask for it's value in an if- statement in "class2" everything works fine. But as soon as I change the value from "test1" to false in a method it does'nt recognize the changes in the if-statement in "class2".

My goal is that the boolean value changes as soon as the rewarded video ends and that the if-statement in class2 recognizes it.

class1:

public boolean test1= true; //This is recognized by the if-statement in class2
...


    @Override
    public void onRewardedVideoAdRewarded(Placement placement) {

        test1 = false; //this is getting ignored by the if-statement in class2


    }

class2:

Class1 class1 = new Class1();

if(class1.test1){
 //Do something
}else{
 //Do something else
}

I hope you can help me, Thank you.

Aucun commentaire:

Enregistrer un commentaire