I want to use the value of 2 editTexts from one activity in another. Here is my code so far. I am getting:
java.lang.NullPointerException.
The Code:
public class AddJob extends AppCompatActivity{
// vars
private BottomNavigationView bottomNavigationView;
private EditText editTextLat, editTextLng;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_job);
TextView textView = findViewById(R.id.activityTitleAddJob);
textView.setText("Add a Job");
editTextLat = findViewById(R.id.editTextLat);
editTextLng = findViewById(R.id.editTextLng);
}
public int getLatitude() {
return new Integer(editTextLat.getText().toString());
}
public int getLongitude() {
return new Integer(editTextLng.getText().toString());
}
}
The Stack Trace:
Here is the code snippet from the map class:
AddJob aj = new AddJob();
int lat = aj.getLatitude();
int lng = aj.getLongitude();
Toast.makeText(aj, lat + " " + lng, Toast.LENGTH_LONG).show();