Hi Rhys, a warm welcome to CodeRanch!
In future, please enclose your code snippets in code tags (see
https://coderanch.com/how-to/java/UseCodeTags) to make them easily readable.
I've done it for you this time.
Since I don't know how comfortable you are with
java and android programming, I'll explain from scratch.
If you already know some of these things, ignore those explanations.
To start off, think of an Intent as a 2-column spreadsheet where each row has a label and a value. Here's an example:
Each row is identified by its label instead of row number.
So rather than asking for value of row 1, we ask for value of row 'name' using Intent.getStringExtra("name").
Or rather than setting the value of row 1, we set the value of row 'name' to 'Rhys' using Intent.putExtra("name", "Rhys").
In your code,
Intent.EXTRA_TEXT is a string constant whose value is "android.intent.extra.TEXT" (see
http://developer.android.com/reference/android/content/Intent.html#EXTRA_TEXT)
and messageText is a variable whose value is the text entered in edit control. So if the text entered is "Hello World", the intent will look like this:
On the receiving side, you have
where EXTRA_MESSAGE is a string constant with value "message". The code means look for a row with label "message" and copy its row value into variable messageText.
As you can see in the above spreadsheet, there is no row with label "message". So messageText will be null.
The correct code should be
Alternatively, use ReceiveMessageActivity.EXTRA_MESSAGE in both classes like this:
EXTRA_MESSAGE is a constant whose value remains "message" and that never changes. You can verify by adding a System.out.println(EXTRA_MESSAGE) after the getStringExtra().