This example allows to implement Privacy Policy activity before Unity game starts
I've tried to publish an Unity game to Chinese stores (like Xiaomi or Vivo).
Some of them reject build because ANDROID_ID value is read BEFORE user accepted Privacy Policy.
Even if I disable ALL Unity services, android_id was still requested by Unity engine.
Chinese stores usually returned reject stacktrace like this (which was helpless for me):
at android.provider.Settings$Secure.getStringForUser()
at android.provider.Settings$Secure.getString(Settings.java:4664)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:164)
at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
As I could find, it's a strange Unity behavior, that is hard to fix. You can read a little about this problem on unity forum
We can run Privacy Policy BEFORE Unity activity starts.
Then, if user accepted privacy policy, load main Unity activity (and never show Privacy Policy on next app starts).
If user declined it, immediately close the game.
- Copy
Assets/Plugins/Android/PrivacyActivity.javafrom this project to yourAssets/Plugins/Androidfolder. - Modify Privacy Policy text in (links are also supported)
- Modify default
Assets/Plugins/AndroidManifest.xml:
<application>
<!--
replace android:name="com.unity3d.player.UnityPlayerActivity"
to android:name="com.gamesofton.privacy.PrivacyActivity"
-->
<activity android:name="com.gamesofton.privacy.PrivacyActivity" android:theme="@style/UnityThemeSelector">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<!--
Register default unity activity, to allow it to start from Privacy Policy activity via Intent
-->
<activity android:name="com.unity3d.player.UnityPlayerActivity" />
</application>