• 5
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

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","**************************");
                                }
                            }
                        });
                    }




                }
            });
      • 2
    • That isn't an error, its a warning. Feel free to ignore it- there's nothing wrong with using lambdas, but it has no practical advantage to switching if you have already written code.

Here's the lambda style

.createUserWithEmailAndPassword(email, pass)
.addOnCompleteListener(task -> {
    if (!task.isSuccessful()) {
        //error message
    }else{
        //success message
    }
});

Additionally, you can put the cursor over the grayed area saying it can be replaced by lambda and press ALT+Enter, a prompt will appear, select Replace with lambda

  • 1
Reply Report

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) {

                        }}
  • 0
Reply Report