Android SDK error: Trying instantiate a class that is not a fragment

独自空忆成欢 提交于 2019-12-03 06:09:37

You should be using FragmentActivity instead of Activity that is because you are using support Fragments and multiple Fragments in your activity main


Edit

You can now use the Appcompat support library and extends AppCompatActivity to support toolbar and fragment for lower api.

In my case it turned out, I was doing stuff in onCreate in the wrong order:

setContentView(R.layout.activity_qr_code_scan);
super.onCreate(savedInstanceState);

instead of

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qr_code_scan);

As you are using fragments in your layout and I suggest you to extend your class from fragment or fragment activity.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!