惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 威少小二orz

团结引擎抖音小游戏一定要手动填缓存资源域名 团结引擎+Addressable+Instant Game打包抖音小游戏 - 威少小二orz 团结引擎发布抖音小游戏(十万个坑已踩完) 团结引擎发布小游戏区分不同平台 团结引擎发布小游戏与js版本SDK的互相调用 Unity发布京东小游戏 LayerMask的使用规范 Unity RectTransform中使用stretch模式时代码动态控制Left、Top、Right、Bottom Unity使用https请求握手失败的处理方案 【MAUI开发】一、初识MAUI Android中使用GSON解析JSON数据 游戏软著渠道的用户协议和隐私协议方案(启动显示方案) C#文件夹复制 C#在Json序列化中动态忽略某些属性或字段 安卓多个Activity大退时自动重启的问题处理 C#中接收到的Json数据中key为数字的问题处理 TapTap实名认证-Android Unity使用Get和Post传递json数据并转换成class对象 Unity获取手机本地应用以及调起apk安装、启动app、安装完成回调 Unity接入穿山甲GroMore广告——重构偏2(Banner广告)
对于UniWebView这种组件违规获取信息的处理
威少小二orz · 2023-02-23 · via 博客园 - 威少小二orz

对于UniWebView这种组件违规获取信息的处理

UniWebView这个组件,原本是用来在Unity里使用浏览器来显示网页信息,但这个组件它自己不安份,偶尔去获取设备的敏感信息,经常导致不能过审。

今天就写一个干掉它的替换方案。

这里只写Andriod方面,举例如下:

1、在UnityPlayer的继承页面中定义一个安卓组件WebView的对象,webView。

2、在安卓的res文件夹的layout里添加一个activity_mian3.xml。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:id="@+id/tvHand"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:gravity="center"
            android:text=""
            android:textColor="#000"/>
        <LinearLayout
            android:id="@+id/llBtns"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_weight="1">

                <Button
                    android:id="@+id/imgbtn_start"
                    android:layout_width="80dp"
                    android:layout_height="40dp"
                    android:text="确定"
                    android:textSize="16dp" />
            </LinearLayout>
        </LinearLayout>

        <WebView
            android:id="@+id/web1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/llBtns"
            android:layout_below="@id/tvHand" />

    </RelativeLayout>

</FrameLayout>

3、将这个网页添加到游戏中。

以下内容中的app,为当前android中activity的单例对象。

public void SetWebView(String url)
    {
        ViewGroup rootGroup = app.findViewById(android.R.id.content);

        LayoutInflater inflater = LayoutInflater.from(app);

        View viewMain3 = inflater.inflate(R.layout.activity_main3, null);
        webview = viewMain3.findViewById(R.id.web1);


        webview.loadUrl(url);
        webview.setWebViewClient(new WebViewClient() {
            @Override

            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                view.loadUrl(url);
                return true;
            }

        });
        //点击确定,关闭对应的网页并移除view。
        viewMain3.findViewById(R.id.imgbtn_start).setOnClickListener(new Button.OnClickListener()
        {
            public void onClick(View v)
            {
                webview.setVisibility(View.GONE);
                rootGroup.removeView(viewMain3);
            }
        });


        webview.setVisibility(View.VISIBLE);

        rootGroup.addView(viewMain3);

    }

4、Android层封装和Unity层调用。

     //由Unity调用的方法。 
    public static void ShowYSXY()
    {

        app.ShowYinSiXieYi();

    }


    //安卓层的封装
    public  void ShowYinSiXieYi()
    {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                SetWebView("http://www.baidu.com");
            }
        });

    }