First of all, I'm a newbie to android.

I have three activities in my Application. i.e, **MainActivity, TC and navigation\_drawer.**

The user enters in MainActivity in the beginning, provided his/her name and enters TC on a button click (Working perfectly fine). Here inside TC there are two buttons "Agree", "Do not Agree" as shown below.

```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TC">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/agree"
        android:text="Agree"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/not_agree"
        android:text="Do not Agree"
        android:layout_below="@id/agree"/>

</RelativeLayout>

```

Now, if the user clicks on **Agree** it should go to **navigation\_drawer** and if clicked on **Do not agree** it should go back to **MainActivity**. The code for it is:

```
public class TC extends AppCompatActivity {

    private Button Agree, NotAgree;

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

        Agree = (Button) findViewById(R.id.agree);
        NotAgree = (Button) findViewById(R.id.not_agree);

        Agree.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(TC.this, "Agree", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(TC.this, navigation_drawer.class);
                startActivity(intent);

            }
        });

        NotAgree.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(TC.this, "Not Agree", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(TC.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }
}

```

***Toast was added just to check if the right method was called or no (And it is calling the right method)***

The AndroidManifest.xml contains(I am not sure if this will help):

```
        <activity android:name=".TC" android:noHistory="true"/>
        <activity android:name=".navigation_drawer" />
        <activity
            android:name=".MainActivity"
            android:noHistory="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

```

The problem is, for some reason no matter which button I click it always redirects to **navigation\_drawer** also for both the buttons the Toast message was shown **as expected.**

I do not know what am I missing here, please suggest a solution. Thank you.