vijay sai vijay sai - 14 days ago 5x
Android Question

Check if the password is temporary on Firebase Android

I am trying to use the


method in Android API to check if the password is a temporary one. Though the method returns literally "true" while printing in log, if I use the method to redirect to a new Activity checking the if condition like

if (authData.getProviderData().get("isTemporaryPassword")){
Intent intent = new Intent(MainActivity.this,PasswordReset.class);
Bundle bundle = new Bundle();

it says "Incompatible Types Required: boolean Found:java.Lang.Object"

Am I missing something??


The method #getProviderData() returns a Map<String, Object>. That's why when you #get() the value, it's an Object. Since you know this is a boolean, you can cast it to Boolean to use in the if condition:

if ((Boolean)authData.getProviderData().get("isTemporaryPassword")) { …

You can't put an Object inside an if condition, only boolean. You can put a Boolean though because autoboxing will take care and convert to boolean.

That also explains why testing for .equals(true) works. When you do that, the method .equals will do the conversion to test if the value stored in this object returned is equivalent to true.