Android Build an Interactive Story App Intents and Multiple Activities Sending Data to a New Activity

Why couldn't you set the variable as private and use it throughout the project?

They're asking to have a parameter in the "StartStory" method but instead of passing a parameter why couldn't you just define what name is in the beginning like so?

public class MainActivity extends AppCompatActivity {

    private EditText mEditText;
    private Button mStartButton;
    private String mName;

    protected void onCreate(Bundle savedInstanceState) {

        mEditText = (EditText) findViewById(;
        mStartButton = (Button) findViewById(;

        mStartButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                mName = mEditText.getText().toString();

                if (mName.matches("")) {
                    Toast.makeText(MainActivity.this, "Please enter a valid User name", Toast.LENGTH_LONG);
                } else {

    private void startStory(String mName) {
        Intent intent = new Intent(this, StoryActivity.class);
        intent.putExtra("UserName", mName);

1 Answer

Ranvir Sahota
Ranvir Sahota
9,844 Points

Though this question may be old I will answer it for anyone else that may get confused. The question was answered in the video but Ben did simply not explain in-depth. The keyword was "coupling" which is defined as a principle in OOP as a way of separation of concerns. The aim to prevent objects being intrinsically tied together,. this helps keep code clean and reusable as stated in the video.

Look at this link: Which is how I came to understand this concept.