Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Daniel Meles
Daniel Meles
1,459 Points

My apps keeps on crashing when I run it

When I select the startActivity on the auto compleat it gives me this

@Override
    public void startActivity(Intent intent) {
        startActivity(intent);
    }  

And When I Run the app the app it crashes is it due to the code I showed or is it because of something else

I also just tried typing

startActivity(intent);

But that did not work

Here is the rest of the class if you need it

package danielmeles.signalfrommars;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    // Declared Variables
    EditText mNameField;
    Button mStartButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Assigned Variables
        mNameField = (EditText) findViewById(R.id.nameEditText);
        mStartButton = (Button) findViewById(R.id.startButton);

        mStartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = mNameField.getText().toString();
                Toast.makeText(MainActivity.this, name, Toast.LENGTH_LONG).show();
                startStory();
            }
        });
    }

    private void startStory() {}
        Intent Intent = new Intent(this, StoryPage.class);

    @Override
    public void startActivity(Intent intent) {
        startActivity(intent);
    }
}