Button b1;int i=0;
b1=(Button) findViewById(R.id.btns);b1.setOnClickListener( new View.OnClickListener() { @SuppressLint("WrongConstant") @Override public void onClick(View view) { if(i==0) { Intent in = new Intent(); in.putExtra( REG_INT_TAG, quantity1); setResult(RESULT_OK,in); finish(); } else if(i==1) { Intent in = new Intent(); in.putExtra( REG_INT_TAG1, quantity1); setResult(RESULT_OK,in); finish(); } i++; }} );