App crashes on "startActivity(intent);" : <p>I want to start a new Activity in the "inntent()" function used in the "buttonn()" function. The app works fine but when I click the button to trigger the intent the app crashes everytime. I've tried different ways to start the intent and changed some things in the Manifest but it still doesn' work.</p>

<p>Here is my MainActivity.java code:</p>

<pre><code>public class MainActivity extends AppCompatActivity {

private BottomNavigationView bottomNavigationView;
ListView list;
private TextView textView;
ImageButton floatButton;
static String category;
static String name;
Button button;

ArrayList&lt;String&gt; aaaa;
ArrayList&lt;String&gt; bbbbb;
ArrayList&lt;String&gt; cccc;
ArrayList&lt;String&gt; dddd;


ArrayList&lt;String&gt; display;


public static int[] pics = {R.drawable.no, R.drawable.yes};

Context context;

public void add() {


    aaaa.add("Example");
    aaaa.add("Example");
    aaaa.add("Example");

    bbbb.add("Example");
    bbbb.add("Example");
    bbbb.add("Example");

    cccc.add("Example");
    cccc.add("Example");

    dddd.add("Example");
    dddd.add("Example");
    dddd.add("Example");
    dddd.add("Example");

}

public void changeDisplay(ArrayList&lt;String&gt; a) {

    display.clear();

    for (int m = 0; m &lt; a.size(); m++) {

        String ep = a.get(m);
        display.add(ep);

    }

}

public void inntent() {

    Intent intent = new Intent(context, GoalsActivity.class);
    intent.putExtra("category", category);
    intent.putExtra("name", name);

    startActivity(intent);

}

public void butonn(View view) {


    inntent();

}



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

    button = (Button)findViewById(R.id.button);

    context = this;
    category = "aaaa";
    name = "";

    aaaa = new ArrayList&lt;String&gt;();
    bbbb = new ArrayList&lt;String&gt;();
    cccc = new ArrayList&lt;String&gt;();
    dddd = new ArrayList&lt;String&gt;();
    display = new ArrayList&lt;&gt;();


    add();
    changeDisplay(aaaa);





    list = (ListView)findViewById(R.id.list_view);
    list.setAdapter(new CustomAdapter(this, display, pics));



    bottomNavigationView = (BottomNavigationView)findViewById(R.id.BottomaNavigationBar);

    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {

            if (item.getItemId() == R.id.wg) {

                changeDisplay(aaaa);
                category = "aaaa";
                ((CustomAdapter) list.getAdapter()).notifyDataSetChanged();

            } else if (item.getItemId() == R.id.qg) {

                changeDisplay(bbbb);
                category = "bbbb";
                ((CustomAdapter) list.getAdapter()).notifyDataSetChanged();

            } else if (item.getItemId() == R.id.challenges) {

                changeDisplay(cccc);
                category = "cccc";
                ((CustomAdapter) list.getAdapter()).notifyDataSetChanged();

            } else if (item.getItemId() == R.id.more) {

                changeDisplay(dddd);
                category = "dddd";
                ((CustomAdapter) list.getAdapter()).notifyDataSetChanged();

            }

            return false;
        }
    });

    floatButton = (ImageButton)findViewById(R.id.imageButton);

    floatButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "TEST", Toast.LENGTH_SHORT).show();
        }
    });


}
</code></pre>

<p>And here is my Manifest:</p>

<pre><code>&lt;application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"&gt;
    &lt;activity
        android:name=".SplashActivity"
        android:screenOrientation="portrait"
        android:theme="@style/SplashTheme"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;activity android:name=".GoalsActivity"
        android:screenOrientation="portrait"&gt;&lt;/activity&gt;
&lt;/application&gt;
</code></pre>
