rahulsain / SharedNotes

Created an Android app that helps organisation to share notes with each other. Built with Firebase
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Null pointer Exception when login fails #3

Closed rahulsain closed 3 years ago

rahulsain commented 3 years ago

Login Activity, if login fails then

fAuth.signInWithEmailAndPassword(mEmail,mPassword).addOnSuccessListener(authResult -> {
            Toast.makeText(Login.this, "Logged  in Successfully", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(getApplicationContext(), MainActivity.class));
        }).addOnFailureListener(e -> {
            Toast.makeText(Login.this, "Login Failed! " + e.getMessage() + " Restart the App!", Toast.LENGTH_LONG).show();
            spinner.setVisibility(View.GONE);

            //close the app

            final Handler handler = new Handler();
            handler.postDelayed(() -> {
                // Do something after 5s = 5000ms
                moveTaskToBack(true);
                android.os.Process.killProcess(android.os.Process.myPid());
                System.exit(1);
            }, 6000);

        });

force shut down the app as there is null check in java

rahulsain commented 3 years ago

Research on what kind of exception it throws

rahulsain commented 3 years ago

Use this whenever we see the error startActivity(new Intent(this, Splash.class)); it will create a new anonymous account but permission denied for deleting the data caused by this user

rahulsain commented 3 years ago

Put a

     try { } catch (NullPointerException | RuntimeExecutionException e) {
                    Toast.makeText(this, "You don't have enough permission to do this operation. Make sure you are logged in first", Toast.LENGTH_LONG).show();    }

to resolve the FirestoreFirebaseException of permission denied

rahulsain commented 3 years ago

data is being deleted if it has some

rahulsain commented 3 years ago

whenever i view the user db it never gets deleted.