I am a beginner and I am trying to make an Intent Calculator, means I am add the inputs through Intent extras and starting a new activity for calculating the input. Finally I am
d is your Intent variable in onActivityResult() so try changing
@Override
protected void onActivityResult(int reqCode, int resCode, Intent d){
super.onActivityResult(reqCode, resCode, d);
TextView result = (TextView) findViewById(R.id.result);
if(reqCode == CALCULATION_COMPLETE && resCode == RESULT_OK){
Intent resultData = getIntent();
Intent calcIntent = getIntent();
to
@Override
protected void onActivityResult(int reqCode, int resCode, Intent d){
super.onActivityResult(reqCode, resCode, d);
TextView result = (TextView) findViewById(R.id.result);
if(reqCode == CALCULATION_COMPLETE && resCode == RESULT_OK){
Intent resultData = d; //This line here
If this doesn't fix your problem then please be a little more clear on what is/isn't happening.
Also, I agree with Monad's comment. While it shouldn't be causing a problem it does seem a little strange to do all of this on onCreate() and you may be a little better off with a Button or some user input. Otherwise, there really is no need for a separate Activity but you could use a function to do the calculation in the first Activity.
Edit
From the Docs
Return the intent that started this activity.
so this won't return the Intent passed from the second Activity in setResult(). It will return an Intent that started this Activity that you would use in onCreate() possibly. In this situation, the Activity isn't being started but brought back to the top of the stack when the second Activity is finished and setResult() is called.