Android 对话框导致应用程序崩溃

Android Dialogue box crashes App

我正在制作一个 activity,它必须在启动时立即将注册表单显示为对话框。但是,activity 总是崩溃。 以下是 activity:

的代码
public class CheckInActivity extends AppCompatActivity{

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



}

public void getDialogue(){

    //Pop dialogue

    AlertDialog.Builder mBuilder= new AlertDialog.Builder(getApplicationContext());
    View mView= getLayoutInflater().inflate(R.layout.dialog_register, null);
    final EditText mPhone= (EditText) mView.findViewById(R.id.etPhone);
    final EditText mPass= (EditText) mView.findViewById(R.id.etPass);
    final EditText mRtPass= (EditText) mView.findViewById(R.id.etRtPass);
    Button mRegisterButton = (Button) mView.findViewById(R.id.btnRegister);


    mBuilder.setView(mView);
    AlertDialog dialog= mBuilder.create();
    dialog.show();

}
}

这是 activity_check_in.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
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="com.example.shashank_pc.trial.CheckInActivity">

</android.support.constraint.ConstraintLayout>

这里是 android_manifest.xml 文件中的 activity

<activity android:name=".CheckInActivity"
        android:theme="@style/Theme.AppCompat">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    </activity>

错误信息如下:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

请帮忙!!

尝试AlertDialog.Builder mBuilder= new AlertDialog.Builder(this);

只需替换这一行

AlertDialog.Builder mBuilder= new AlertDialog.Builder(getApplicationContext());

android.support.v7.app.AlertDialog.Builder mBuilder= new android.support.v7.app.AlertDialog.Builder(getApplicationContext());

或者只需将 android:theme="@style/Theme.AppCompat.Light" 添加到 AndroidManifest.xml 文件中的应用程序标签。