我正在使用 android studio 制作统一插件,但这里有问题。一些 SDK 提供仅使用 AppcompatActivity
来制作 fragment 但我的MainActivity
, 正是 UnityPlayerActivity
不是 AppCompatActivity
.所以它会导致错误......任何人都可以解决这个问题?
最佳答案
如果不了解您尝试与之交互的 SDK 的更多信息,就很难确切地告诉您如何解决您的问题。但是,有关这些类(class)的一些背景信息可能会对您有所帮助:UnityPlayerActivity
是 Android 的 Activity
的子类类(class)。这是用于现代 Android Activity 的主要类。AppCompatActivity
也是 Activity
的子类类,旨在让您在较旧的 Android 设备上使用某些功能(例如 fragment )。来自 the docs :
Base class for activities that wish to use some of the newer platform features on older Android devices. Some of these backported features include:
- Using the action bar, including action items, navigation modes and more with the setSupportActionBar(Toolbar) API.
- Built-in switching between light and dark themes by using the Theme.AppCompat.DayNight theme and AppCompatDelegate.setDefaultNightMode(int) API.
- Integration with DrawerLayout by using the getDrawerToggleDelegate() API.
所以在OO方面:
UnityPlayActivity
是一个 Activity
AppCompatActivity
是一个 Activity
UnityPlayActivity
不是 AppCompatActivity
(他们有 sibling 关系)。 如果您绝对需要
AppCompatActivity
, 处理此问题的一种方法是修改 UnityPlayActivity
代码扩展AppCompatActivity
反而。您可以see an example of that here .
关于android - 有没有办法将 UnityPlayerActivity 用作 AppcompatActivity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55275867/