Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

I want to use lambda expression instead of addOnCompleteListener(new OnCompleteListener<AuthResult>() { {

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Shreya Bansal

User

( 7 months ago )

 

i am getting error while using OnCompleteListerner in Java 8 SE Anonymous new OnCompleteListener() can be replaced with lambda less... (Ctrl+F1) Inspection info: This inspection reports all anonymous classes which can be replaced with lambda expressions Lambda syntax is not supported under Java 1.7 or earlier JVMs.

            mAuth.createUserWithEmailAndPassword(email1, pass ).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful())
                    {
                        currentuser=FirebaseAuth.getInstance().getCurrentUser();
                        String uid= currentuser.getUid();
                        secondaryDB=firebaseDatabase.getInstance().getReference().child("android_demo").child("users").child(uid);
                        HashMap<String, String> userMap= new HashMap<>();
                        userMap.put("name",name);
                        userMap.put("fcm",fcm);
                        userMap.put("email",email);
                        userMap.put("mobile",mobile);
                        userMap.put("userid",userid+"");
                        userMap.put("image_url", profileimageUrl);

                        Log.e("DB Called","DatabaseCalled");
                        secondaryDB.setValue(userMap).addOnCompleteListener(new OnCompleteListener<Void>() {
                            @Override
                            public void onComplete(@NonNull Task<Void> task) {

                                if (task.isSuccessful())
                                {
                                    Log.v("success","**************************");
                                }
                            }
                        });
                    }




                }
            });

usr_profile.png
Jadav Payeng

User

( 7 months ago )

As Lambda is introduce in Java 8. Make sure you have installed Java 8 and above JDK Version. Lambda expression for "createUserWithEmailAndPassword" :

mAuth.createUserWithEmailAndPassword(emailId, password)
                    .addOnCompleteListener(OnCompleteListener { task ->
                        if (task.isSuccessful) {

                        }}

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif