When we want an intent to carry some data to another application component, we use an extra of that intent. An intent is simply a key value pair. We first define our key as a public constant, and give it a value. e.g.
public static final String extra_key = "com.example.myapp.MESSAGE";
We also have to assign the key the data which needs to be carried by the intent. e.g.
String extra_value = editText.getText().toString();
Then we make an extra of the intent like:
intent.putExtra(extra_key, extra_value);
MY QUESTIONS:
Why does the key have to be public?
Why do we need to intialize the key in the first place, why can't we just declare it, because it will be assigned a value (the data to be carried by the intent) anyway. So why couldn't we do something like
public static final String extra_key;
I have read that the key value should include the reverse domain name so that it is unique in case other packages plunge in. But what is the point of giving it a unique value when it will anyway be assigned another value which is the data to be carried by the intent.
Thank you in advance.