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>
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);
}
}
}
这两个文件要在Project的Plugin/Andriod下,这样它们才会参与Build