Unity和android之间的通信(adt方式)

一 Unity调用Andorid方法

 1.1 这里介绍俩种方法,第一种是直接调用currentActivity,就是当前的Activity。

     Unity代码:

           

/*******************
 *  Title:介入android sdk介入
 *  Author:CW
 *  ScriptName:   SDKForAndrodTest
 *  Des:
 ******************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SDKForAndrodTest : MonoBehaviour 
{

    private AndroidJavaClass jc = null;
    private AndroidJavaObject jo = null;

    void Awake()
    {
        Debug.Log("这里是Unity的Awake");
        //得到android里面的类
        jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        //得到当前的Anorid的Activity对象
        jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
       
    }
    void OnGUI()
    {
        if(GUI.Button(new Rect(0,0,100,100),""))
        {
            if(jo!=null)
            {
                //test是android里面的方法名称
                jo.Call("test", "这是来自Unity的消息");
            }
        }
    }
}

   android里面的代码:

     新建一个GameMainActivity类继承UnityPlayerActivity,并且重写onCreate方法。

package com.CW.AndroidSDK;

import com.unity3d.player.UnityPlayer;

import android.graphics.PixelFormat;
import android.os.Bundle;
import android.text.style.SuperscriptSpan;
import android.util.Log;
import android.view.Window;

public class GameMainActivity  extends UnityPlayerActivity
{
	@Override protected void onCreate (Bundle savedInstanceState)
	{
	  super.onCreate(savedInstanceState);
	}
       //这里是Untiy调用的方法
	private void test(String s)
	{
		Log.i("unity", "unity 调用了 java 方法:"+s);
	}
}

  之后修改AndroidManifest文件,将当前的activity改成GameMainActivity

2 第二种方法是直接调用自己新建的Activity方法(这种我在测试的时候好像只能调用android里面的静态方法)

  在adt里面新建一个包和一个类如下:

 SDKAPI里面写上Unity要调用的方法。

 

package com.sdk.api;

import android.R.integer;
import android.util.Log;

public class SDKAPI {

	private static int test(String s)
	{
		Log.i("unity", "unity 调用了 java 方法:"+s);
		return 0;
	}
}

Unity里面的代码:

/*******************
 *  Title:
 *  Author:CW
 *  ScriptName:   SDKForAndrodTest2
 *  Des:
 ******************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SDKForAndrodTest2 : MonoBehaviour {

    private AndroidJavaClass jc = null;

	// Use this for initialization
	void Start () {
        //包名.类名
        jc = new AndroidJavaClass("com.sdk.api.SDKAPI");
        Debug.Log("这里是Unity的Awake");
	}

    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 100, 100), ""))
        {
            if (jc != null)
            {
                jc.CallStatic<int>("test", "这是来自Unity的消息");
            }
        }
    }

    private void CallBack(string str)
    {
        Debug.Log("这里是Android的回调:" + str);
    }
}

 

 真机调试的时候都打印出出对应的log信息

二 android里面调用Unity的方法

  这个很简单,调用UnityPlayer.UnitySendMessage方法就可以了,值得注意的是传参数的时候只能传一个字符串过去。

package com.sdk.api;
import org.json.JSONException;
import org.json.JSONObject;

import com.CW.AndroidSDK3.UnityPlayerActivity;
import com.unity3d.player.UnityPlayer;

import android.R.integer;
import android.util.Log;

public class SDKAPI {

	private static int test(String s)
	{
		Log.i("unity", "unity 调用了 java 方法:"+s);
		JSONObject jsonObject=new JSONObject();
		try {
			jsonObject.put("Key", "这是Android发送给Unity的消息");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//回调给Unity
		//第一个参数是游戏物体的名称
		//第二个参数是方法名
		//第三个参数是发送的消息字符串
		UnityPlayer.UnitySendMessage("SDKForAndrodTest", "CallBack", jsonObject.toString());
		return 0;
		
	}
}

 打印的Log的信息如下:

 三 编写框架实现SDK的接入

 1 Untiy端

1.1 抽象出基类

/*******************
 *  Title:SDK接入
 *  Author:CW
 *  ScriptName:   SDKBase
 *  Des:SDK基类
 ******************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SDKBase
{
    /// <summary>
    /// 初始化函数
    /// </summary>
    /// <param name="flag"></param>
    public virtual void Init(int flag=0) { }
    /// <summary>
    /// 登入
    /// </summary>
    public virtual void Login() {}
    /// <summary>
    /// 登出
    /// </summary>
    public virtual void Logout() { }
    /// <summary>
    /// 支付
    /// </summary>
    public virtual void Pay(int num,string orderId ) { }
    /// <summary>
    /// 游戏中心
    /// </summary>
    public virtual void GameCenter() { }

}

 1.2 实现Android的SDK

/*******************
 *  Title:三国无双案例
 *  Author:CW
 *  ScriptName:   SDKForAndroid
 *  Des:接入安卓SDK
 ******************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SDKForAndroid:SDKBase 
{
#if UNITY_ANDROID && !UNITY_EDITOR
    private AndroidJavaClass _jc;
    public SDKForAndroid():base()
    {
        _jc = new AndroidJavaClass("com.sdk.SDKAPI.SDKAPI");
    }
    public override void Init(int flag = 0)
    {
       if(_jc!=null)
        {
            _jc.CallStatic("Init",flag);
            Debug.Log("初始化SDK");
        }
    }

   public override void Login()
   {
       if (_jc != null)
       {
           _jc.CallStatic("Login");
       }
   }

    public override void Logout()
    {
        if (_jc != null)
        {
            _jc.CallStatic("Logout");
        }
    }

    public override void Pay(int num,string orderId)
    {
        if (_jc != null)
        {
            _jc.CallStatic("Pay",num,orderId);
        }
    }

    public override void GameCenter()
    {
        if (_jc != null)
        {
            _jc.CallStatic("GameCenter");
        }
    }

#endif
}

 1.3管理这些SDK

/*******************
 *  Title:SDK接入
 *  Author:CW
 *  ScriptName:   SDKMgr
 *  Des:SDK管理器
 ******************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SDKMgr : MonoBehaviour 
{
    /// <summary>
    /// 单利
    /// </summary>
    private static SDKMgr _instance;
    /// <summary>
    /// 得到实例
    /// </summary>
    public static SDKMgr Instance
    {
        get
        {
            if(_instance==null)
            {
                GameObject tmpGo = new GameObject("SDKMgr");
                _instance = tmpGo.AddComponent<SDKMgr>();
            }
            return _instance;
        }
    }

    private SDKBase _sdkAPI;
    void Awake()
    {
#if UNITY_EDITOR
        _sdkAPI = new SDKBase();
#elif UNITY_ANDROID
         Debug.Log("Awake");
        _sdkAPI = new SDKForAndroid();
#endif
    }

    /// <summary>
    /// 初始化函数
    /// </summary>
    /// <param name="flag"></param>
    public  void Init(int flag = 0) 
    {
        _sdkAPI.Init(flag);
    }
    /// <summary>
    /// 登入
    /// </summary>
    public  void Login(LoginListener listener)
    {
        _currentListner = listener;
        _sdkAPI.Login();
    }
    /// <summary>
    /// 登出
    /// </summary>
    public  void Logout()
    {
        _sdkAPI.Logout();
    }
    /// <summary>
    /// 支付
    /// </summary>
    public  void Pay(PayData payData) 
    {
        CurrentPayData = payData;
        _sdkAPI.Pay(CurrentPayData.Num,CurrentPayData.OrderID);
    }
    /// <summary>
    /// 游戏中心
    /// </summary>
    public  void GameCenter()
    {
        _sdkAPI.GameCenter();
    }


    public PayData CurrentPayData;
    /// <summary>
    /// 支付数据
    /// </summary>
    public class PayData
    {
        /// <summary>
        /// 支付数量
        /// </summary>
        public int Num;
        /// <summary>
        /// 订单号
        /// </summary>
        public string OrderID;

        public PayData(int num,string orderId)
        {
            Num=num;
            OrderID=orderId;
        }
    }
    private LoginListener _currentListner;
    public interface LoginListener
    {
        void OnSucess(string uid);
        void OnFail();
        void OnCancel();
    }

    #region Android回调Unity
    private void LogicCallBack(string jsonObj)
    {
        if(string.IsNullOrEmpty(jsonObj))
        {
            if(_currentListner!=null)
            {
                _currentListner.OnFail();
            }
            else
            {
                Debug.LogError("_currentListner is null");
            }
        }
        else if(jsonObj.Equals("-1"))
        {
            if (_currentListner != null)
            {
                _currentListner.OnCancel();
            }
            else
            {
                Debug.LogError("_currentListner is null");
            }
        }
        else
        {
            if (_currentListner != null)
            {
                _currentListner.OnSucess(jsonObj);
            }
            else
            {
                Debug.LogError("_currentListner is null");
            }
        }
    }
    #endregion
}

1.4 Unity端的测试脚本

/*******************
 *  Title:三国无双案例
 *  Author:CW
 *  ScriptName:   SDKTest
 *  Des:
 ******************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SDKTest : MonoBehaviour {

	
    void OnGUI()
    {
        if(GUI.Button(new Rect(0,0,100,50),"Init"))
        {
           SDKMgr.Instance.Init();
        }else if(GUI.Button(new Rect(0,60,100,50),"Login"))
        {
            SDKMgr.Instance.Login(new LoginCallBack());
        }
        else if (GUI.Button(new Rect(0, 120, 100, 50), "Logout"))
        {
            SDKMgr.Instance.Logout();
        }
        else if (GUI.Button(new Rect(0, 190, 100, 50), "Pay"))
        {

            SDKMgr.Instance.Pay(new SDKMgr.PayData(5,"测试订单ID"));
        }
        else if (GUI.Button(new Rect(0, 270, 100, 50), "GameCenter"))
        {
            SDKMgr.Instance.GameCenter();
        }
    }

    public class LoginCallBack:SDKMgr.LoginListener
    {

        public void OnSucess(string uid)
        {
            Debug.Log("登录成功:"+uid);   
        }

        public void OnFail()
        {
            Debug.Log("登录失败");   
        }

        public void OnCancel()
        {
            Debug.Log("取消登录");   
        }
    }
}

 

 2 ADT方面的代码(以接入百度SDK为例,详细的接入百度SDK步骤可以看百度SDK的接入文档,这里只说明接入的流程)

   2.1 把untiy的工程导出Android工程(不会百度一下就出来了),然后创建出负责和adt通信的包和类名,并且导入百度SDK的库文件。我的目录结构如下:

 

  2.2将我们的项目去引用这个库文件

 

  2.3下面我们编写SDKAPI这个类,代码如下:

package com.sdk.SDKAPI;

import android.R.integer;

import com.CW.AndroidSDK.MainActivity;

/*这里的方法要和Unity里面的要对应
 * */
public class SDKAPI {

	/*
	 * SDK初始化
	 * */
    public static  void Init(int flag) 
    {
        MainActivity.myHandler.sendEmptyMessage(SDKUtility.E_SDKFunType.INIT.ordinal());
    }
    /*
     * 登入
     * */
    public static void Login()
    {
    	 MainActivity.myHandler.sendEmptyMessage(SDKUtility.E_SDKFunType.LOGIN.ordinal());
    }
    /*
     * 登出
     * */
    public static void Logout()
    {
    	 MainActivity.myHandler.sendEmptyMessage(SDKUtility.E_SDKFunType.LOGOUT.ordinal());
    }
    
    public static PayData currPayData;
   /*
    * 支付
    * */
    public static void Pay(int num,String orderId) 
    {
    	 currPayData=new PayData(num,orderId);
    	 MainActivity.myHandler.sendEmptyMessage(SDKUtility.E_SDKFunType.PAY.ordinal());
    }
   /*
    * 游戏中心
    * */
    public static void GameCenter()
    {
    	 MainActivity.myHandler.sendEmptyMessage(SDKUtility.E_SDKFunType.GAMECENTER.ordinal());
    }
    /*
     * 支付数据
     * */
    public static  class PayData
    {
    	/*金币分
    	 * */
    	public int num;
    	/*订单号
    	 * */
    	public String orderIdString;
    	
    	public PayData(int num,String orderId)
    	{
    		this.num=num;
    		this.orderIdString=orderId;
    	}
    }
}

   2.4编写MainActivity,这个类必须继承UnityPlayerActivity并且重写onCreate方法。(这样做是百度SDK文档要求的)

  这个类主要的作用去调用百度SDK里面的库文件,所以有些方法是文档里面要求的。而我们的SDKAPI类就是去调用这个类里面的一些方法,从而实现交互,下面是这个类的主要代码:

package com.CW.AndroidSDK;

import java.util.UUID;

import android.R.string;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.Window;
import android.widget.Toast;

import com.baidu.gamesdk.ActivityAdPage;
import com.baidu.gamesdk.ActivityAdPage.Listener;
import com.baidu.gamesdk.ActivityAnalytics;
import com.baidu.gamesdk.BDGameSDK;
import com.baidu.gamesdk.BDGameSDKSetting;
import com.baidu.gamesdk.BDGameSDKSetting.Domain;
import com.baidu.gamesdk.IResponse;
import com.baidu.gamesdk.ResultCode;
import com.baidu.platformsdk.PayOrderInfo;
import com.sdk.SDKAPI.SDKAPI;
import com.sdk.SDKAPI.SDKUtility;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;


public class MainActivity extends UnityPlayerActivity
{
	public static Activity CurrentActivity;
	public static MyHandler myHandler;//百度SDK
	private ActivityAnalytics mActivityAnalytics;//百度SDK
	private ActivityAdPage mActivityAdPage;
	@Override protected void onCreate (Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		 CurrentActivity=this;
		  mActivityAnalytics = new ActivityAnalytics(this);
		  mActivityAdPage = new ActivityAdPage(this, new Listener(){
				@Override
				public void onClose() {
					//TODO 关闭暂停页面,CP可以让玩家继续玩游戏
					Toast.makeText(getApplicationContext(), "继续游戏", Toast.LENGTH_LONG).show();
				}
				
			}); 
		myHandler=new MyHandler();
		
	}
	@Override protected void onDestroy()
	{
		BDGameSDK.destroy();
		mUnityPlayer.quit();
		super.onDestroy();
	}
	@Override
	protected void onResume() { 
		super.onResume(); 
		mActivityAdPage.onResume(); 
		mActivityAnalytics.onResume();
		
	}
	
	
	@Override
	protected void onStop() { 
		super.onStop();
		mActivityAdPage.onStop();
	}
	
	@Override
	protected void onPause() { 
		super.onPause();
		mActivityAdPage.onPause();
		mActivityAnalytics.onPause();
		
	}
	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
		BDGameSDK.closeFloatView(this);//关掉悬浮框
	}
	
	
	
	public class MyHandler extends Handler
	{
		public MyHandler()
		{
			
		}
		 public MyHandler(Looper L) {
	            super(L);
	        }

	        /*
	         * 子类必须重写该方法,接受该消息
	         * */
	        @Override
	        public void handleMessage(Message msg)
			{
				if(msg.what==SDKUtility.E_SDKFunType.INIT.ordinal())
				{
					initBDGameSDK();
					Log.i("Unity", "调用了SDK初始化方法");
				}else if(msg.what==SDKUtility.E_SDKFunType.LOGIN.ordinal())
				{
					BDSDKLogic();
					Log.i("Unity", "调用了SDK登入方法");
				}else if(msg.what==SDKUtility.E_SDKFunType.LOGOUT.ordinal())
				{
					BDSDKLogOut();
					Log.i("Unity", "调用了SDK登出方法");
				}else if(msg.what==SDKUtility.E_SDKFunType.PAY.ordinal())
				{
					BDSDKPay(SDKAPI.currPayData.num,SDKAPI.currPayData.orderIdString);
					Log.i("Unity", "调用了SDK支付方法");
				}else if(msg.what==SDKUtility.E_SDKFunType.GAMECENTER.ordinal())
				{
					Log.i("Unity", "调用了SDK游戏中心方法");
				}
				super.handleMessage(msg);
				Log.i("Unity", "-----");
			}
	}
	
	
	
	
	
	
	/*public static Handler MyHandler =new Handler()
	{
		public void handleMessage(Message msg)
		{
			if(msg.what==SDKUtility.E_SDKFunType.INIT.ordinal())
			{
			
				Log.i("Unity", "调用了SDK初始化方法");
			}else if(msg.what==SDKUtility.E_SDKFunType.LOGIN.ordinal())
			{
				Log.i("Unity", "调用了SDK登入方法");
			}else if(msg.what==SDKUtility.E_SDKFunType.LOGOUT.ordinal())
			{
				Log.i("Unity", "调用了SDK登出方法");
			}else if(msg.what==SDKUtility.E_SDKFunType.PAY.ordinal())
			{
				Log.i("Unity", "调用了SDK支付方法");
			}else if(msg.what==SDKUtility.E_SDKFunType.GAMECENTER.ordinal())
			{
				Log.i("Unity", "调用了SDK游戏中心方法");
			}
			super.handleMessage(msg);
			Log.i("Unity", "-----");
		}
		
	};*/
	
	 private void setSuspendWindowChangeAccountListener(){//设置切换账号事件监听(个人中心界面切换中心)
			BDGameSDK.setSuspendWindowChangeAccountListener(new IResponse<Void>(){

				@Override
				public void onResponse(int resultCode, String resultDesc,
						Void extraData) { 
					 switch(resultCode){
					 case ResultCode.LOGIN_SUCCESS:
						 //TODO 登录成功,不管之前是什么情况,游戏内都要切换成新的用户
						 //返回主界面,重新刷新
						 Toast.makeText(getApplicationContext(), "鐧诲綍鎴愬姛", Toast.LENGTH_LONG).show();
						 break;
					 case ResultCode.LOGIN_FAIL:
						//TODO 登录失败,游戏内部之前如果是已经被登录的,要清楚自己记录的登录状态,设置成未登录。如果之前为登录,不用处理
						 Toast.makeText(getApplicationContext(), "鐧诲綍澶辫触", Toast.LENGTH_LONG).show();
						 break;
					 case ResultCode.LOGIN_CANCEL:					 
						//TODO 取消,操作前后的登录状态没变换
						 break; 
						 
					 } 
				}
				
			});
		}
	/*
	 * 初始化SDK
	 * */
	private void initBDGameSDK()
	{
		BDGameSDKSetting mBDGameSDKSetting = new BDGameSDKSetting();
		mBDGameSDKSetting.setAppID(3067515);//APPID
		mBDGameSDKSetting.setAppKey("f3Os4GAOqxgm79GqbnkT9L8T");//APPKEY
		mBDGameSDKSetting.setDomain(Domain.DEBUG);//
		mBDGameSDKSetting.setOrientation(BDGameSDKSetting.Orientation.PORTRAIT);
		 
		BDGameSDK.init(this, mBDGameSDKSetting, new IResponse<Void>(){

			@Override
			public void onResponse(int resultCode, String resultDesc,
					Void extraData) {
				switch(resultCode){
				case ResultCode.INIT_SUCCESS:
					//初始化成功
					
					break;
					
				case ResultCode.INIT_FAIL:
					//初始化失败
					
				default:
					Toast.makeText(CurrentActivity, "启动失败", Toast.LENGTH_LONG).show();
					finish();
					
				}
				
			}
			
		}); 
	}
	/*
	 * 登录
	 * */
	 public void BDSDKLogic()
	 {
		   BDGameSDK.login(new IResponse<Void>() {
				
				@Override
				public void onResponse(int resultCode, String resultDesc, Void extraData) { 
					Log.d("login", "this resultCode is " + resultCode);
					String hint = "";
					switch(resultCode){
					case ResultCode.LOGIN_SUCCESS:
						hint="登录成功";
						//拿到用户ID
					    String uid=	BDGameSDK.getLoginUid();
					    //UnityPlayer.UnitySendMessage("SDKMgr", "BDLoginCallBack", uid);
					    SDKUtility.SendMsgToUnity(SDKUtility.CallBackFunName.LOGINCALLBACK_STRING, uid);
					    //显示悬浮按钮
					    BDGameSDK.showFloatView(CurrentActivity);
					    //切换账号
					    setSuspendWindowChangeAccountListener();
						break; 
					case ResultCode.LOGIN_CANCEL:
						 SDKUtility.SendMsgToUnity(SDKUtility.CallBackFunName.LOGINCALLBACK_STRING, "-1");
						hint="取消登录";
						break;
					case ResultCode.LOGIN_FAIL:
						 SDKUtility.SendMsgToUnity(SDKUtility.CallBackFunName.LOGINCALLBACK_STRING, "");
						hint="登录失败";
					default:
						SDKUtility.SendMsgToUnity(SDKUtility.CallBackFunName.LOGINCALLBACK_STRING, "");
						hint="登录失败";
					} 
					Toast.makeText(getApplicationContext(), hint, Toast.LENGTH_LONG).show(); 
				}
			});
	   }
	  /*
	  * 登出
	  * */
	   public void BDSDKLogOut()
	   {
		   BDGameSDK.logout();
	   }
	   /*支付(定额支付)
	    * */
	   public void BDSDKPay(int num,String oderId)
	   {
		   PayOrderInfo payOrderInfo = buildOrderInfo(num,oderId);
			if(payOrderInfo == null){
				return;
			}
			
			BDGameSDK.pay(payOrderInfo, null, 
					new IResponse<PayOrderInfo>(){
				  
						@Override
						public void onResponse(int resultCode, String resultDesc,
								PayOrderInfo extraData) 
						{
							String resultStr = "";
							switch(resultCode){
							case ResultCode.PAY_SUCCESS:
								resultStr = "支付成功:" + resultDesc;
								break;
							case ResultCode.PAY_CANCEL:
								resultStr = "取消支付";
								break;	
							case ResultCode.PAY_FAIL:
								resultStr = "支付失败" + resultDesc;
								break;	
							case ResultCode.PAY_SUBMIT_ORDER:
								resultStr ="支付失败"; 
								break;	
							}
							Toast.makeText(getApplicationContext(), resultStr, Toast.LENGTH_LONG).show();
							 
						}
				
			});
	   }
	   /*
	    * 构建订单信息
	    * 总金额
	    * 订单号
	    * */
	   public PayOrderInfo buildOrderInfo(int amount,String oderId){
			String cpOrderId = UUID.randomUUID().toString();//
			String goodsName = "金币";
			String totalAmount = String.valueOf(amount);
			int ratio = 1;
			String extInfo = oderId;
			
			if(TextUtils.isEmpty(totalAmount)){
				totalAmount = "0";
			}
			 
			
			PayOrderInfo payOrderInfo = new PayOrderInfo();
			payOrderInfo.setCooperatorOrderSerial(cpOrderId);
			payOrderInfo.setProductName(goodsName); 
			long p = Long.parseLong(totalAmount); 
			payOrderInfo.setTotalPriceCent(p);
			payOrderInfo.setRatio(ratio);
			payOrderInfo.setExtInfo(extInfo);
			
			return payOrderInfo;
		}
	   

}

 注意我们要修改manifest文件。将Application里面的Android:name 改成

 android:name="com.CW.BaiDuSDKPro1.GameApplication"

 Application里面的Activity:name改成:

 android:name="com.CW.AndroidSDK.MainActivity"

 除了这些之外还有一些service和uses-permission还有其他的acrivity按照百度SDK的文档要求全部复制进去

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.CW.BaiDuSDKPro1" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner" android:name="com.CW.BaiDuSDKPro1.GameApplication">
    <activity android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:name="com.CW.AndroidSDK.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
      <!-- ↓↓↓ SDK ↓↓↓ -->


        <!-- 0-百度 1-多酷 2-91 -->

        <meta-data android:name="BDPlatformType" android:value="0" />
        
        
        <meta-data android:name="BDGameVersion" android:value="3.2.0" />
        
          <activity
            android:name="com.baidu.platformsdk.LoginActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:excludeFromRecents="true"
            android:theme="@style/bdp_dialog_style_fullscreen"/>
        <activity
            android:name="com.baidu.platformsdk.AssistActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:excludeFromRecents="true"
            android:theme="@style/bdp_dialog_style_fullscreen"/> 
        <activity
            android:name="com.baidu.platformsdk.BindPhoneActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:excludeFromRecents="true"
            android:theme="@style/bdp_dialog_style_fullscreen"/>
        
        <activity
            android:name="com.baidu.platformsdk.CashierDeskActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false" 
            android:theme="@style/bdp_dialog_style_fullscreen"
            android:windowSoftInputMode="adjustPan"/>
        
        <activity
            android:name="com.baidu.platformsdk.WebActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false" 
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:windowSoftInputMode="adjustPan"/>

        
        <activity
            android:name="com.baidu.platformsdk.ModifyPasswordActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:excludeFromRecents="true"
            android:theme="@style/bdp_dialog_style_fullscreen"/>
        <activity
            android:name="com.baidu.platformsdk.ThirdPartyLoginActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:excludeFromRecents="true"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:exported="false"/>
        <activity
            android:name="com.baidu.platformsdk.VisitorBindActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:excludeFromRecents="true"
            android:theme="@style/bdp_dialog_style_fullscreen"/> 
        <activity
            android:name="com.baidu.platformsdk.BaiduBeanDetailActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:windowSoftInputMode="adjustPan"
            android:theme="@style/bdp_dialog_style_fullscreen" /> 
        <activity
            android:name="com.baidu.platformsdk.OrderDetailActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:windowSoftInputMode="adjustPan"
            android:theme="@style/bdp_dialog_style_fullscreen" />
         
        
        <activity
            android:name="com.baidu.platformsdk.SapiWebActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:windowSoftInputMode="adjustPan"
            android:theme="@style/bdp_dialog_style_fullscreen" />
        <activity
            android:name="com.baidu.platformsdk.SapiLoginProxyActivity"
            android:configChanges="orientation|navigation|screenSize|keyboard|keyboardHidden"
            android:exported="false"
            android:windowSoftInputMode="adjustPan"
            android:theme="@style/bdp_dialog_style_fullscreen" />
        
        <service
            android:name="com.baidu.platformsdk.BDPlatformService"
            android:exported="false" />

        <!-- ↑↑↑ SDK ↑↑↑ -->


        <!-- ↓↓↓ 百度钱包 ↓↓↓ -->
        <activity
            android:name="com.baidu.android.pay.ui.WelcomeActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivityWelcome"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.PayResultActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.baidu.android.pay.ui.PwdCheckActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateVisible" >
        </activity>
        <activity
            android:name="com.baidu.android.pay.ui.PwdSetActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateVisible" >
        </activity>
        <activity
            android:name="com.baidu.android.pay.ui.PwdConfirmActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateVisible" >
        </activity>
        <activity
            android:name="com.baidu.android.pay.ui.PwdPayActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivitTranslucent"
            android:windowSoftInputMode="stateVisible" />
        <activity
            android:name="com.baidu.android.pay.ui.PwdPaySmsActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivitTranslucent"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.WebViewActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.baidu.android.pay.ui.BindFirstActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name="com.baidu.android.pay.ui.BindSecondActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.BindSecondCreditAcitvity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.BindSecondCredit2Activity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.BindThirdActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name="com.baidu.android.pay.ui.SelectBindCardActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.LoginActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.PassNormalizeActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
        <activity
            android:name="com.baidu.android.pay.ui.OrderHomeActivity"
            android:configChanges="keyboardHidden|navigation|orientation|screenSize"
            android:excludeFromRecents="true"
            android:exported="false"
            android:theme="@style/EbpayThemeActivit"
            android:windowSoftInputMode="stateHidden" />
             

        <!-- ↑↑↑ 百度钱包 ↑↑↑ -->
        
        <!-- ↓↓↓ passport ↓↓↓ -->
        <activity
            android:name="com.baidu.sapi2.utils.LoginProtectAcitivity"
            android:screenOrientation="portrait"
            android:theme="@style/bdp_SapiTheme"
            android:windowSoftInputMode="adjustPan" />
        <!-- ↑↑↑ passport ↑↑↑ -->


        <!-- ↓↓↓ 银联SDK ↓↓↓ -->
        <activity android:name="com.unionpay.uppay.PayActivity"
            android:screenOrientation="landscape" />
        <!-- ↑↑↑ 银联SDK ↑↑↑ -->
        
        <!-- ↓↓↓ 支付宝插件 ↓↓↓ -->
        <activity android:name="com.alipay.sdk.app.H5PayActivity"
				   android:configChanges="orientation|keyboardHidden|navigation"
				   android:exported="false"
				   android:screenOrientation="behind" />
        <activity android:name="com.alipay.sdk.auth.AuthActivity"
				   android:configChanges="orientation|keyboardHidden|navigation"
				   android:exported="false"
				   android:screenOrientation="behind" />
        <!-- ↑↑↑ 支付宝插件 ↑↑↑ -->
        
        <!-- ↓↓↓ 多酷SDK ↓↓↓ --> 
        <activity
            android:name="com.duoku.platform.ui.DKContainerActivity"
            android:configChanges="orientation|keyboardHidden|navigation|screenSize"
            android:launchMode="singleTop"
            android:theme="@style/StyledIndicators" >
        </activity>

        <service android:name="com.duoku.platform.service.DKSuspensionService" />

        <!-- 贴吧 start -->
        <activity
            android:name="com.baidu.tiebasdk.ext.motu.SelectBarActivity"
            android:configChanges="orientation|keyboardHidden|navigation" />
        <activity
            android:name="com.baidu.tiebasdk.account.InputUserNameActivity"
            android:configChanges="orientation|keyboardHidden|navigation"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.account.LoginActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.account.Register2Activity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.account.ActivationActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.account.ProtocolActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.frs.FrsActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.frs.FrsImageActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.mention.MentionActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.mention.ReplyMeActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.mention.AtMeActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.pb.NewPbActivity"
            android:configChanges="orientation|keyboardHidden|navigation"
            android:windowSoftInputMode="adjustResize|stateHidden" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.pb.ImagePbActivity"
            android:configChanges="orientation|keyboardHidden|navigation"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.write.WriteActivity"
            android:configChanges="orientation|keyboardHidden|navigation"
            android:windowSoftInputMode="stateVisible|adjustResize" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.write.VcodeActivity"
            android:configChanges="orientation|keyboardHidden|navigation"
            android:windowSoftInputMode="stateVisible|adjustResize" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.write.NewVcodeActivity"
            android:configChanges="orientation|keyboardHidden|navigation"
            android:windowSoftInputMode="stateHidden" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.write.AtListActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.write.WriteImageActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.pb.ImageActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity
            android:name="com.baidu.tiebasdk.pb.WebActivity"
            android:configChanges="orientation|keyboardHidden|navigation" >
            <intent-filter>
            </intent-filter>
        </activity>
        <activity android:name="com.baidu.tiebasdk.more.AccountActivity" >
            <intent-filter>
            </intent-filter>
        </activity>
        <!-- 贴吧activity end -->
        
        <!-- 贴吧 service begin -->
        <service
            android:name="com.baidu.tiebasdk.service.TiebaUpdateService"
            android:enabled="true" >
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.tiebasdk.service.TiebaFullUpdateService"
            android:enabled="true" >
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.tiebasdk.service.ClearTempService"
            android:enabled="true" >
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.tiebasdk.service.FatalErrorService"
            android:enabled="true" >
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.tiebasdk.service.TiebaSyncService"
            android:enabled="true" >
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.tiebasdk.service.TiebaMessageService"
            android:enabled="true" >
            <intent-filter>
                <action android:name="com.baidu.tiebasdk.service.Message" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.tiebasdk.service.TiebaPrepareImageService"
            android:enabled="true" >
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
        <!-- 贴吧 service end -->


        <!-- push service client -->
        <receiver android:name="com.duoku.platform.push.MyReceiver" >
            <intent-filter>
                <action android:name="com.duoku" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.duoku.platform.push.PushMessageReceiver" >
            <intent-filter>

                <!-- 接收push消息 -->
                <action android:name="com.baidu.android.pushservice.action.MESSAGE" />
                <!-- 接收bind,unbind,fetch,delete等反馈消息 -->
                <action android:name="com.baidu.android.pushservice.action.RECEIVE" />
                <action android:name="com.baidu.android.pushservice.action.notification.CLICK" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.baidu.android.pushservice.PushServiceReceiver"
            android:process=":bdservice_v1" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                <action android:name="com.baidu.android.pushservice.action.notification.SHOW" />
                <action android:name="com.baidu.android.pushservice.action.media.CLICK" />
                <action android:name="android.intent.action.MEDIA_MOUNTED" />
                <action android:name="android.intent.action.USER_PRESENT" />
                <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
                <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.baidu.android.pushservice.RegistrationReceiver"
            android:process=":bdservice_v1" >
            <intent-filter>
                <action android:name="com.baidu.android.pushservice.action.METHOD" />
                <action android:name="com.baidu.android.pushservice.action.BIND_SYNC" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REMOVED" />

                <data android:scheme="package" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.baidu.android.pushservice.PushService"
            android:exported="true"
            android:process=":bdservice_v1" >
            <intent-filter>
                <action android:name="com.baidu.android.pushservice.action.PUSH_SERVICE" />
            </intent-filter>
        </service>
        <service
            android:name="com.baidu.android.pushservice.CommandService"
            android:exported="true" />
        <!-- push service end -->


        <!-- 贴吧 receiver start -->
        <receiver android:name="com.baidu.tiebasdk.service.TiebaReceiver" >
            <intent-filter>
                <action android:name="com.baidu.tiebasdk.broadcast.service" />
                <action android:name="com.baidu.tiebasdk.broadcast.sync" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.baidu.tiebasdk.service.InstallReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <action android:name="android.intent.action.PACKAGE_REMOVED" />

                <data android:scheme="package" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.baidu.tiebasdk.service.SyncLoginReceiverForAs" >
            <intent-filter>
                <action android:name="com.baidu.tiebasdk.broadcast.syncLoginFromAS" />
            </intent-filter>
        </receiver>

        <!-- 贴吧  receiver end -->
        <!-- ↑↑↑ 多酷SDK ↑↑↑ -->
    
  </application>
  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" />
  <uses-feature android:glEsVersion="0x00020000" />
  <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" />
  
    <!-- ↓↓↓ SDK ↓↓↓ -->
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    

    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
	<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <!-- ↑↑↑ SDK ↑↑↑ -->
    
    <!-- ↓↓↓ DK SDK ↓↓↓ --> 
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" /> 
    <uses-permission android:name="android.permission.CALL_PHONE" />
    
</manifest>

 测试运行的界面如下:

 

posted @ 2017-10-23 11:36  围墙外的世界  阅读(1177)  评论(0编辑  收藏  举报