Android Studio App Crashes When Opening Second Activity

I am trying to code an app where it connects to Bluetooth on the Main Activity Page and then on the Second Activity page it will turn on the silent ringer mode. Every time I click on the button to open up the next activity, the app closes down. There are no errors according to Android Studio.

Here is my SecondActivity.java file

package fonephree.fonephreeconnecttobluetooth;

import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

    public class SecondActivity extends Activity {
        Button button;
        AudioManager audiomanager;
        Context context;
        TextView textview;

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

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

            textview = (TextView)findViewById(R.id.textView2);

            context = getApplicationContext();

            audiomanager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    audiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);

                    textview.setText("Silent Mode Enable");

                }
            });
        }

    }

and here is my activity_second.xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:background="@android:color/holo_orange_dark"
    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="fonephree.fonephreeconnecttobluetooth.SecondActivity">

        <Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Silent" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/button6"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="44dp"
            android:text="Silent Mode"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/phree"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

And just in case the error is in my AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="fonephree.fonephreeconnecttobluetooth">

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />

    <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">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SecondActivity"
            android:label="@string/title_activity_second"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="fonephree.fonephreeconnecttobluetooth.SecondActivity" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

EDIT

I fixed the code but now the app only shuts off when I press the button and it wasn’t in silent mode before opening the app. The button just reinforces silent mode, it doesn’t actually turn it on.

From the information what you have given, you are setting your XML to be activity_main, while the button6 and textview2 are defined in activity_second.xml

So your onCreate should like below to solve the problem

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

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

            textview = (TextView)findViewById(R.id.textView2);

            context = getApplicationContext();

            audiomanager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    audiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);

                    textview.setText("Silent Mode Enable");

                }
            });
        }