i am using firebase and i developed an android app(java) where users login through Phone. but when the user login and finished the app and restart the app it shows again the login activity and again OTP is to be sent. How to solve this. the code of the main activity is given.
'''
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
public class MainActivity extends AppCompatActivity {
private EditText editTextMobile;
public Button buttonContinue;
private FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
editTextMobile=findViewById(R.id.editTextMobile);
buttonContinue=findViewById(R.id.buttonContinue);
buttonContinue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String mobile=editTextMobile.getText().toString().trim();
if(mobile.isEmpty()|| mobile.length()<10){
editTextMobile.setError("Enter Valid number");
editTextMobile.requestFocus();
return;
}
Intent intent=new Intent(MainActivity.this, VarifyPhoneNumber.class);
intent.putExtra("mobile", mobile);
startActivity(intent);
}
});
}
@Override
public void onStart() {
super.onStart();
if(firebaseAuth.getCurrentUser()!=null){
Intent intent=new Intent(MainActivity.this,ProfileActivity.class);
startActivity(intent);
}
}
}
'''