Click here to Skip to main content
15,501,147 members
Home / Discussions / Java
   

Java

 
GeneralRe: JAVA IF ELSE STATEMENT (HELP ME) Pin
tomatomoa3-Nov-20 3:18
Membertomatomoa3-Nov-20 3:18 
GeneralRe: JAVA IF ELSE STATEMENT (HELP ME) Pin
Richard MacCutchan3-Nov-20 4:11
mveRichard MacCutchan3-Nov-20 4:11 
QuestionLooking for a node.js developer for advanced disk wiping software (Almost complete) Pin
fixapc22-Oct-20 6:45
Memberfixapc22-Oct-20 6:45 
AnswerRe: Looking for a node.js developer for advanced disk wiping software (Almost complete) Pin
Richard MacCutchan22-Oct-20 7:09
mveRichard MacCutchan22-Oct-20 7:09 
QuestionLog4j2 Migration Pin
Member 1496731916-Oct-20 5:21
MemberMember 1496731916-Oct-20 5:21 
AnswerRe: Log4j2 Migration Pin
Richard MacCutchan16-Oct-20 5:38
mveRichard MacCutchan16-Oct-20 5:38 
QuestionJackson ObjectMapper valueToTree method also write valueType and integral but no actual value Pin
Manish K. Agarwal12-Oct-20 0:02
MemberManish K. Agarwal12-Oct-20 0:02 
QuestionWhy can't we make a sign up with phone number in android studio project Pin
Member 145474583-Oct-20 3:46
MemberMember 145474583-Oct-20 3:46 
Hi guys I created a project in android studio which has 2 types of login system the

 1. Sign in with email and password 

 2. Login with phone number

I have a problem in login with phone number 

I have 3 activities in project which in 

 1. I am taking the the login with email and password

 2. Is I am taking the login with phone number 

 3. I am checking if the email is verified or not

So if the email is verified the person can go to app inside 

But when I login with phone number it go to the 3rd activitiy to the email verification but I want it go to the app not to the verify email activity 

Here is my code for main activity


----------

    @Override
    protected void onCreate(final Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mAuth = FirebaseAuth.getInstance();
        currentUser = mAuth.getCurrentUser();

        myViewPager = (ViewPager) findViewById(R.id.main_tabs_pager);
        myTabsaccessorAdopter = new TabsAccessorAdopter(getSupportFragmentManager());
        myViewPager.setAdapter(myTabsaccessorAdopter);

        myTabLayout = (TabLayout) findViewById(R.id.main_tabs);
        myTabLayout.setupWithViewPager(myViewPager);
    }

    @Override
    protected void onStart()
    {
        super.onStart();
        if (currentUser == null)
        {
            SendUserToLoginActivity();
        }
        else
        {
            if(!currentUser.isEmailVerified())
            {
                SendUserToVerifyEmailActivity();
            }
        }
    }

    private void SendUserToLoginActivity()
    {
        Intent loginIntent = new Intent(MainActivity.this,LoginActivity.class);
        startActivity(loginIntent);
    }

    private void SendUserToVerifyEmailActivity()
    {
        Intent verifyEmailIntent  = new Intent(MainActivity.this,VerifyEmailActivity.class);
        startActivity(verifyEmailIntent);
    }

    private void SendUserToMainActivity()
    {
        Intent mainIntent  = new Intent(MainActivity.this,MainActivity.class);
        startActivity(mainIntent);
    }
    }


-------------------------------
 And here is my PHone login code



    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register__with__phone__number_);


        mAuth =FirebaseAuth.getInstance();
        loadingBar = new ProgressDialog(this);

        Initialize();
        Second_Fourth.registerCarrierNumberEditText(Second_Fifth);

        First_Fifth.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
               String code = First_Fourth.getSelectedCountryCode();
                First_Layout.setVisibility(View.INVISIBLE);
                Second_Layout.setVisibility(View.VISIBLE);
                Third_Layout.setVisibility(View.INVISIBLE);
                Second_Fourth.setCountryForPhoneCode(Integer.parseInt(code));
            }
        });

        Second_Seven.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                String phoneNumber = Second_Fifth.getText().toString();
                phoneNumber = Second_Fourth.getFullNumberWithPlus();
                if(TextUtils.isEmpty(phoneNumber))
                {
                    Toast.makeText(Register_With_Phone_Number_Activity.this, "Number is recquired", Toast.LENGTH_SHORT).show();
                }
                else
                {
                    loadingBar.setTitle("Phone verification");
                    loadingBar.setMessage("please wait...");
                    loadingBar.setCanceledOnTouchOutside(false);
                    loadingBar.show();

                    PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNumber,60,TimeUnit.SECONDS,Register_With_Phone_Number_Activity.this,mCallbacks);

                }
            }
        });

        mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks()
        {
            @Override
            public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential)
            {
                signInWithPhoneAuthCredential(phoneAuthCredential);
            }

            @Override
            public void onVerificationFailed(@NonNull FirebaseException e)
            {
                Toast.makeText(Register_With_Phone_Number_Activity.this, "Invalid phone number", Toast.LENGTH_SHORT).show();
                loadingBar.dismiss();
                First_Layout.setVisibility(View.INVISIBLE);
                Second_Layout.setVisibility(View.VISIBLE);
                Third_Layout.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken)
            {
                super.onCodeSent(s, forceResendingToken);
                loadingBar.dismiss();
                mVerificationId = s;
                mResendToken = forceResendingToken;
                First_Layout.setVisibility(View.INVISIBLE);
                Second_Layout.setVisibility(View.INVISIBLE);
                Third_Layout.setVisibility(View.VISIBLE);
            }
        };

        Second_Eight.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                SendUserToRegisterNumberActivity();
            }
        });

        Third_Fourth.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                String verificationcode = Third_Third.getText().toString();
                if (verificationcode.isEmpty())
                {
                    Toast.makeText(Register_With_Phone_Number_Activity.this, "Verification code first", Toast.LENGTH_SHORT).show();
                }
                else
                {
                    loadingBar.setTitle("verification code");
                    loadingBar.setMessage("please wait...");
                    loadingBar.setCanceledOnTouchOutside(false);
                    loadingBar.show();

                    PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId,verificationcode);

                    signInWithPhoneAuthCredential(credential);
                }
            }
        });

    }

    private void signInWithPhoneAuthCredential(final PhoneAuthCredential credential)
    {
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
                {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task)
                    {
                        if (task.isSuccessful())
                        {
                            loadingBar.dismiss();
                            Toast.makeText(Register_With_Phone_Number_Activity.this, "Logged in Successful", Toast.LENGTH_SHORT).show();
                            SendUserToMainActivity();
                        }
                        else
                        {
                            loadingBar.dismiss();
                            Toast.makeText(Register_With_Phone_Number_Activity.this, "Error", Toast.LENGTH_SHORT).show();
                        }
                    }
                });
    }

    private void Initialize()
    {
        First_Layout = (LinearLayout) findViewById(R.id.first_layout);
        Second_Layout = (LinearLayout) findViewById(R.id.second_layout);
        Third_Layout = (LinearLayout) findViewById(R.id.third_layout);

        First_Fifth = (Button) findViewById(R.id.first_fifth);
        Second_Seven = (Button) findViewById(R.id.second_seven);
        Second_Eight = (Button) findViewById(R.id.second_eight);
        Third_Fourth = (Button) findViewById(R.id.third_fourth);

        First_Fourth = (CountryCodePicker) findViewById(R.id.first_fourth);
        Second_Fourth = (CountryCodePicker) findViewById(R.id.second_fourth);

        Second_Fifth = (EditText) findViewById(R.id.second_fifth);
        Third_Third = (EditText) findViewById(R.id.third_third);
    }

    private void SendUserToRegisterNumberActivity()
    {
        Intent registernumberIntent = new Intent(Register_With_Phone_Number_Activity.this,Register_With_Phone_Number_Activity.class);
        startActivity(registernumberIntent);
    }

    private void SendUserToMainActivity()
    {
        Intent mainIntent  = new Intent(Register_With_Phone_Number_Activity.this,MainActivity.class);
        startActivity(mainIntent);
    }
}

Question2d java graphics Pin
Member 149532531-Oct-20 3:07
MemberMember 149532531-Oct-20 3:07 
AnswerRe: 2d java graphics Pin
CHill601-Oct-20 3:09
mveCHill601-Oct-20 3:09 
AnswerRe: 2d java graphics Pin
Richard MacCutchan1-Oct-20 4:02
mveRichard MacCutchan1-Oct-20 4:02 
Questionjava programmimg Pin
Member 1494135617-Sep-20 20:36
MemberMember 1494135617-Sep-20 20:36 
AnswerRe: java programmimg Pin
Member 1494135617-Sep-20 20:39
MemberMember 1494135617-Sep-20 20:39 
AnswerRe: java programmimg Pin
Sandeep Mewara17-Sep-20 21:23
mveSandeep Mewara17-Sep-20 21:23 
AnswerRe: java programmimg Pin
Gerry Schmitz18-Sep-20 1:44
mveGerry Schmitz18-Sep-20 1:44 
GeneralRe: java programmimg Pin
Dave Kreskowiak18-Sep-20 5:33
mveDave Kreskowiak18-Sep-20 5:33 
QuestionIntegrating keycloak with spring security Pin
arunken16-Sep-20 22:30
Memberarunken16-Sep-20 22:30 
QuestionHelp me! Pin
Member 1492738231-Aug-20 9:30
MemberMember 1492738231-Aug-20 9:30 
AnswerRe: Help me! Pin
ZurdoDev31-Aug-20 10:37
professionalZurdoDev31-Aug-20 10:37 
AnswerRe: Help me! Pin
ZurdoDev31-Aug-20 10:38
professionalZurdoDev31-Aug-20 10:38 
AnswerRe: Help me! Pin
Afzaal Ahmad Zeeshan31-Aug-20 18:52
mveAfzaal Ahmad Zeeshan31-Aug-20 18:52 
AnswerRe: Help me! Pin
Richard MacCutchan31-Aug-20 22:11
mveRichard MacCutchan31-Aug-20 22:11 
QuestionHow can I solve the following error: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext; Pin
Member 1469623621-Jul-20 19:41
MemberMember 1469623621-Jul-20 19:41 
AnswerRe: How can I solve the following error: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext; Pin
Richard MacCutchan21-Jul-20 22:41
mveRichard MacCutchan21-Jul-20 22:41 
AnswerRe: How can I solve the following error: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext; Pin
ZurdoDev31-Aug-20 10:37
professionalZurdoDev31-Aug-20 10:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.