0

I have created Fragment and when click a button get popup like dialog alter view. in that view include google sign in button. when i connect to the firebase and continue the implementation after the startActivityForResult i need to override onActivityResult method. but popup corresponded class extend another Dialog class and can not override onActivityResult method. when going to override it shows method does not override method from its superclass error. how to solve this. and how to implement my firebase login.

thank you. here is my code

public class DialogGoogle extends Dialog { private Activity activity; @BindView(R.id.btn_google) LinearLayout btnGoogle; private GoogleSignInClient mGoogleSignInClient; private FirebaseAuth mAuth; private int RC_SIGN_IN = 1; public DialogGoogle(Activity a, boolean isTab, int width, int height) { super(a, R.style.DialogTheme); this.activity = a; this.isTab = isTab; this.windowWidth = width; this.windowHeight = height;} 

in onCreate method

// Initialize Firebase Auth mAuth = FirebaseAuth.getInstance(); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(this.activity.getString(R.string.default_web_client_id)) .requestEmail() .build(); mGoogleSignInClient = GoogleSignIn.getClient(this.activity,gso); 

After i created some method

public void signInGoogle() {Intent signInIntent = mGoogleSignInClient.getSignInIntent(); startActivityForResult(signInIntent, RC_SIGN_IN);} 

in after startActivityForResult() I need to get result and i used onActivityResult() but i cannot override method in that DialogGoogle class. i run usually signInGoogle() method in button click

4
  • 1
    Instead of describing your problem, please add the related code to the question. Commented Apr 10, 2020 at 13:23
  • I want to override onActivityResult method in normal java class. Commented Apr 10, 2020 at 13:34
  • 1
    You cannot do that unless you extend AppCompatActivity. In that case, it becomes an activity. Commented Apr 10, 2020 at 13:40
  • i edit my problem with code part. please give me a solution Commented Apr 14, 2020 at 6:21

1 Answer 1

0

You start Fragments in a Activity and there you Override the onActivityResult method but first you start your auth like in the documentation:

List<AuthUI.IdpConfig> providers = Arrays.asList( new AuthUI.IdpConfig.EmailBuilder().build(), new AuthUI.IdpConfig.PhoneBuilder().build(), new AuthUI.IdpConfig.GoogleBuilder().build(), new AuthUI.IdpConfig.FacebookBuilder().build(), new AuthUI.IdpConfig.TwitterBuilder().build()); // Create and launch sign-in intent startActivityForResult( AuthUI.getInstance() .createSignInIntentBuilder() .setAvailableProviders(providers) .build(), RC_SIGN_IN); 

RC_SIGN_IN is a static field and this is the indicator that you can check if the Activity is finished.

Sign up to request clarification or add additional context in comments.

3 Comments

Sir from my fragment button(when click), its open Dialog popup and its popup have google sign in button. that Dialog have another SignInDialog class with extend DialogClass. and all button click function in popup included in SignInDialog class. then I want to implement Google Sign in method from SignInDialog class. but from that SignInDialog class i cannot override onActivityResult method because SignInDialog class is not a activity class. so what i have do? please give me a solution.
So just to be shure, your app open a dialog and that dialog opens the Google Login dialog right?
I edit my question with code part. please give a solution

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.