i want to learn how to send message data from 1 activity to another and receive the data in onActivityResult
i am not sure if this is the right way but hope you can show me the right way.
Mainactivity on button1 click
Intent returnIntent = new Intent();
returnIntent.putExtra("demo1");
setResult(RESULT_OK,returnIntent);
on button2 click
Intent returnIntent = new Intent();
returnIntent.putExtra("sarah22");
setResult(RESULT_OK,returnIntent);
Mainactivity2
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if ("demo1") {
                Context context = getApplicationContext();
                CharSequence text = "button1 demo1 received";
                int duration = Toast.LENGTH_SHORT;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();
            }
if ("sarah22") {
                Context context = getApplicationContext();
                CharSequence text = "Button2 sarah22 received";
                int duration = Toast.LENGTH_SHORT;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();
            }
        }
    }
 
     
     
    