Android kalkulator wynik działania w osobnej intencji

0

Witam stworzyłem o to taki kalkulator lecz chciałbym aby wynik działania nie wyświetlał się w textview1 lecz w nowej intencji wiem że potrzebuje do wysłania taki kod lecz nie mam pojęcia gdzie dokładnie go wstawić i jak odebrać w nowej intencji wynik

Intent intent = new Intent(getBaseContext(), MainIntencjeActivity.class);
        intent.putExtra("OPERATION", "PLUS");
        startActivityForResult(1010, intent);

Kalkulator:

package com.example.proj2a;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class MainActivity extends Activity {
	
	double a,b;

	EditText ed1, ed2;
	TextView tv1;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

     tv1 = (TextView)findViewById(R.id.textView1);
     ed1 = (EditText)findViewById(R.id.editText1);
     ed2 = (EditText)findViewById(R.id.editText2);
     Button plus = (Button)findViewById(R.id.button1);
     plus.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String txt = ed1.getText().toString();
			a = Double.parseDouble(txt);
			txt = ed2.getText().toString();
			b = Double.parseDouble(txt);
			tv1.setText(Double.toString((a+b)));
		}
	});
     
     Button minus = (Button)findViewById(R.id.button2);
     minus.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String txt = ed1.getText().toString();
			a = Double.parseDouble(txt);
			txt = ed2.getText().toString();
			b = Double.parseDouble(txt);
			tv1.setText(Double.toString((a-b)));
		}
	});
     
     Button mnoz = (Button)findViewById(R.id.button3);
     mnoz.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String txt = ed1.getText().toString();
			a = Double.parseDouble(txt);
			txt = ed2.getText().toString();
			b = Double.parseDouble(txt);
			tv1.setText(Double.toString((a*b)));
		}
	});
     
     Button dziel = (Button)findViewById(R.id.button4);
     dziel.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String txt = ed1.getText().toString();
			a = Double.parseDouble(txt);
			txt = ed2.getText().toString();
			b = Double.parseDouble(txt);
			
			if(b==0)
			tv1.setText("Nie przez 0");
			else 
				tv1.setText(Double.toString((a/b)));	
		}
	});
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
0

Odbiera się tak:

Intent intent = getIntent();
String jakisString = intent.getStringExtra("TWOJ_TAG");
 

więcej szczegółów w dokumentacji androida

0

Hmmm jeśli chce odebrać wynik działania kalkulatora to także w stringu ?

1 użytkowników online, w tym zalogowanych: 0, gości: 1