I'm new to Android Studio and java, so hopefully you can help me. I want to pass a double variable from on activity to the next. But I'm unsure what needs so go in the defaultValue in the receiving activity.
Here is the code from activity one:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button weiter = (Button)findViewById(R.id.weiter);
weiter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText EingabeBreite = (EditText)findViewById(R.id.breite);
double breite = Double.parseDouble(EingabeBreite.getText().toString());
Intent rüber = new Intent(getApplicationContext(), Main2Activity.class);
getIntent().putExtra("next", breite);
startActivity(rüber);
Here is the code from the second activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
TextView ergebnis = (TextView)findViewById(R.id.textView2);
Bundle extras = getIntent().getExtras();
double breite = extras.getDouble("next");
ergebnis.setText(Double.toString(breite));