While working in Android Dev Studio, I have been working on two classes, MainActivity and Main2Activity.
MainActivity
public class MainActivity extends AppCompatActivity {
public static final String EXTRA_MESSAGE = ".com.company.name.practiceapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View view) {
Intent intent = new Intent(this, Main2Activity.class);
EditText editText = (EditText) findViewById(R.id.editText);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
How would I go about using the String message in Main2Activity?
note: I browsed through many other similar questions but none of the answers said how to use it. The class is public (as you can see), so I couldn't figure out why I couldn't use message.