|
@@ -0,0 +1,86 @@
|
|
|
+package com.unity3d.player;
|
|
|
+import android.app.Activity;
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.SharedPreferences;
|
|
|
+import android.content.pm.ActivityInfo;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.webkit.WebResourceError;
|
|
|
+import android.webkit.WebResourceRequest;
|
|
|
+import android.webkit.WebView;
|
|
|
+import android.webkit.WebViewClient;
|
|
|
+
|
|
|
+public class PrivacyActivity extends Activity implements DialogInterface.OnClickListener {
|
|
|
+
|
|
|
+ // 隐私协议内容
|
|
|
+ final String privacyContext =
|
|
|
+ "欢迎使用本游戏,在使用本游戏前,请您充分阅读并理解 <a href=\"http://yhxy.goufuguiwxw.com\">" +
|
|
|
+ "《用户协议》</a>和<a href=\"http://ysxy.goufuguiwxw.com\">《隐私政策》</a>各条;\n" +
|
|
|
+ "1.保护用户隐私是本游戏的一项基本政策,本游戏不会泄露您的个人信息;\n" +
|
|
|
+ "2.我们会根据您使用的具体功能需要,收集必要的用户信息(如申请设备信息,存储等相关权限);\n" +
|
|
|
+ "3.在您同意App隐私政策后,我们将进行集成SDK的初始化工作,会收集您的android_id、Mac地址、指定包名信息、ICCID、IMEI和应用安装列表,以保障App正常数据统计和安全风控;\n" +
|
|
|
+ "4.为了方便您的查阅,您可以通过“设置”重新查看该协议;\n" +
|
|
|
+ "5.您可以阅读完整版的隐私保护政策了解我们申请使用相关权限的情况,以及对您个人隐私的保护措施。";
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+
|
|
|
+ // 如果已经同意过隐私协议则直接进入Unity Activity
|
|
|
+ if (GetPrivacyAccept()){
|
|
|
+ EnterUnityActivity();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 弹出隐私协议对话框
|
|
|
+ ShowPrivacyDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示隐私协议对话框
|
|
|
+ private void ShowPrivacyDialog(){
|
|
|
+ WebView webView = new WebView(this);
|
|
|
+ webView.loadData(privacyContext, "text/html", "utf-8");
|
|
|
+ AlertDialog.Builder privacyDialog = new AlertDialog.Builder(this);
|
|
|
+ privacyDialog.setCancelable(false);
|
|
|
+ privacyDialog.setView(webView);
|
|
|
+ privacyDialog.setTitle("提示");
|
|
|
+ privacyDialog.setNegativeButton("拒绝",this);
|
|
|
+ privacyDialog.setPositiveButton("同意",this);
|
|
|
+ privacyDialog.create().show();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
+ switch (i){
|
|
|
+ case AlertDialog.BUTTON_POSITIVE://点击同意按钮
|
|
|
+ SetPrivacyAccept(true);
|
|
|
+ EnterUnityActivity(); //启动Unity Activity
|
|
|
+ break;
|
|
|
+ case AlertDialog.BUTTON_NEGATIVE://点击拒绝按钮,直接退出App
|
|
|
+ finish();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 启动Unity Activity
|
|
|
+ private void EnterUnityActivity(){
|
|
|
+ Intent unityAct = new Intent();
|
|
|
+ unityAct.setClassName(this, "com.unity3d.player.UnityPlayerActivity");
|
|
|
+ this.startActivity(unityAct);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 本地存储保存同意隐私协议状态
|
|
|
+ private void SetPrivacyAccept(boolean accepted){
|
|
|
+ SharedPreferences.Editor prefs = this.getSharedPreferences("PlayerPrefs", MODE_PRIVATE).edit();
|
|
|
+ prefs.putBoolean("PrivacyAcceptedKey", accepted);
|
|
|
+ prefs.apply();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取是否已经同意过
|
|
|
+ private boolean GetPrivacyAccept(){
|
|
|
+ SharedPreferences prefs = this.getSharedPreferences("PlayerPrefs", MODE_PRIVATE);
|
|
|
+ return prefs.getBoolean("PrivacyAcceptedKey", false);
|
|
|
+ }
|
|
|
+}
|