当前位置:   article > 正文

Unity开发 解决TapTap隐私协议_unity游戏 隐私协议制作

unity游戏 隐私协议制作

TapTap安卓隐私协议

XML文件 下面的所有com.DefaultCompany.AddresableDemo都改成你的PackageName

<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" 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">
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="android.notch_support" android:value="true" />
    </activity> 
        <activity android:name="com.DefaultCompany.AddresableDemo.MoeNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
    <meta-data android:name="unity.build-id" android:value="af96e734-2061-4fc4-9d9a-f14290704772" />
  </application>
  <uses-feature android:glEsVersion="0x00030000" />
  <uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

Java文件 此处代码时借鉴别个的

package com.DefaultCompany.AddresableDemo;   //此处需要修改为你的包体相关名称 Unity的PlayerSetting里面

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.unity3d.player.UnityPlayerActivity;

public class MoeNativeActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (!isTaskRoot()) {
            Intent intent = getIntent();
            String action = intent.getAction();
            if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action != null && action.equals(Intent.ACTION_MAIN)) {
                finish();
                return;
            }
        }

        Boolean anInt = false;

        // 隐私协议相关
        SharedPreferences base = getSharedPreferences("base",MODE_PRIVATE);
        anInt = base.getBoolean("isFirstStart",true);

        if (anInt==true){
            AlertDialog.Builder dialog=new AlertDialog.Builder(MoeNativeActivity.this);
            dialog.setTitle("隐私协议");  //设置标题
            dialog.setMessage("隐私政策\n" +
                    "\n" +
                    "更新时间:【2022】年【7】月【16】日\n" +
                    "\n" +
                    "生效时间:【2022】年【7】月【16】日\n" +
                    "这里写的是自己游戏的隐私内容,可能会很长"+
                    "\n" +
                    " \n");  //设置内容
            dialog.setCancelable(true);  //是否可以取消
            dialog .setNegativeButton("拒绝", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                    android.os.Process.killProcess(android.os.Process.myPid());
                }
            });

            dialog.setPositiveButton("同意", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences.Editor editor = base.edit();
                    editor.putBoolean("isFirstStart",false);
                    editor.commit();

     // 玩家点击同意后,跳转到 Unity 的 Activity
                    Intent intent = new Intent(MoeNativeActivity.this, UnityPlayerActivity.class);
                    startActivity(intent);
                }
            });
            dialog.show();

        }
        else{
                // 已经同意过了,直接跳转到 Unity 的 Activity
                Intent intent = new Intent(MoeNativeActivity.this, UnityPlayerActivity.class);
                startActivity(intent);
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72

这两个文件要在Project的Plugin/Andriod下,这样它们才会参与Build

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/56770
推荐阅读
相关标签
  

闽ICP备14008679号