- Home /
AndroidManifest.xml: meta-data unityplayer.UnityActivity
I've been recently looking at some sample AndroidManifest.xml files for several Unity projects and periodically, some projects have a main app Activity with the following meta-data tag:
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
Does anyone know what purpose adding that particular meta-data tag does?
Not all sample projects that I've seen have that and the Unity Android plugin documentation makes no reference to it. I haven't been able to find any explanation for it anywhere in my searches online. It just seems to appear. Any ideas? Hoping someone from Unity can chime in :)
Update (2016/08/25): I've done a bit of investigating and it seems to have made it's appearance in the default generated AndroidManifest.xml since Unity 4.3.3f1. By setting the value to "true" it appears to impose a fixed set of attributes/values on the main Activity tag. If the value is "false", or the meta-data tag doesn't exist in the AndroidManifest.xml, then the main Activity tag is left unmodified from the result of merging of the manifest files found within the Assets/Plugins/Android/ folder. This would suggest that it's a toggle for ensuring the necessary attributes are used when a Unity-based Activity (UnityPlayerActivity, UnityPlayerNativeActivity, UnityPlayerProxyActivity) -- not a subclass of one -- is set as the main application Activity. I'm just guessing, of course.
Answer by canyon_gyh · Sep 30, 2018 at 06:56 AM
I guess that control UnityPlayer or UnityPlayer's Child , UnityPlayer can control Android Fragment is closely related
Answer by julian_cruz · Oct 24, 2018 at 02:45 PM
What it does, it's select the activity to be patched with the following properties.
android:screenOrientation="fullSensor" android:launchMode="singleTask"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
android:hardwareAccelerated="false"
if none activities have this property, the following filter will be by the activity name, trying to find the following matches.
"com.unity3d.player.UnityPlayerNativeActivity",
"com.unity3d.player.UnityPlayerActivity",
"com.unity3d.player.UnityPlayerProxyActivity"
In case of these statements are false, a warning will be thrown with this message with the specific properties required. "Unable to find unity activity in manifest. You need to make sure orientation attribute is set to {0} manually."
keep in mind that you can set the properties manually.
It's important to note that the patched values are dependent on your Android Player Settings -- for example, it patches in android:screenOrientation="fullSensor"
if the Player Setting "Default Orientation" is set to "Auto Rotation", but if you set it to "Portrait" then Unity will patch the activity to have: android:screenOrientation="portrait"