1、java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
第一行代码,强制下线功能:
代码运行到弹出提示框的时候报错,查阅网上资料,有的说activity继承自AppCompatActivity,需要设置theme为Theme.AppCompat,检查AndroidManifest.xml,发现已经设置theme为Theme.AppCompat,不是这里的原因,再查阅资料,发现,在构建alertDialog的时候,需要传入context,代码里传入的是全局的上下文(Application),应该传入Activity.this
错误代码如下:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
正确代码如下:
AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this);
参考链接:
https://www.jianshu.com/p/47155d2925b2
https://www.jianshu.com/p/628ac6b68c15