I am in an android class project and I have almost finished it but I need to pass some variables from one activity to another, it gives me NullPointerException and searching I have not found anything.
logcat
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference at com.group3.cebancburger.AddBurger.(AddBurger.java:31 )
The attempt that I do in class.
MainActivity:
(The views)
nomb = (EditText)findViewById(R.id.nombre);
dire = (EditText)findViewById(R.id.direccion);
tele = (EditText)findViewById(R.id.telefono);
email = (EditText)findViewById(R.id.email);
(try)
intent = new Intent(DatosCliente.this, AnadirHamburguesa.
intent.putExtra("nombre", nomb.getText().toString());
intent.putExtra("direccion", dire.getText().toString());
intent.putExtra("telefono", tele.getText().toString());
intent.putExtra("email", email.getText().toString());
startActivity(intent);
AddBurger(the getIntent)
Bundle extras = getIntent().getExtras();
String nom = extras.getString("nombre");
String dire = extras.getString("direccion");
String tele = extras.getString("telefono");
String email = extras.getString("email");
Try to retrieve the information in your AddBurger activity without using Bundle, as follows
AddBurger
If you use Bundle to pass data you must create the Bundle and pass it in the intent
In AddHamburger
In the future try to use Parcelable or Serializable to pass objects from one activity to another. For example if you have an object of type Client that implements the Parcelable class
In NextActivity: