unity 打开广告ads退到后台返回后台,再返回app会杀死掉广告ads

1.在AndroidManifest.xml里面添加

<activity android:name="com.adsdk.unity.UnityPlayerProxyActivity"  android:launchMode="singleTop" android:exported="true">
      <intent-filter >
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>

2.把下面的UnityPlayerProxyActivity添加进来就可以直接使用了

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.adsdk.unity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class UnityPlayerProxyActivity extends Activity {
    public UnityPlayerProxyActivity() {
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!this.isTaskRoot()) {
            Intent intent = this.getIntent();
            if (intent != null) {
                String action = intent.getAction();
                if (intent.hasCategory("android.intent.category.LAUNCHER") && "android.intent.action.MAIN".equals(action)) {
                    this.finish();
                    return;
                }
            }
        }

        try {
            Class clazz = Class.forName("com.unity3d.player.UnityPlayerActivity");
            Intent intent = new Intent(this, clazz);
            this.startActivity(intent);
        } catch (ClassNotFoundException var4) {
            var4.printStackTrace();
        }

    }
}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容