美文网首页
安卓支付

安卓支付

作者: Kyle_An | 来源:发表于2018-04-12 19:37 被阅读0次

    调用里面的方法就可以了

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine.UI;
    using UnityEngine.UI;
    public class Android_share : MonoBehaviour
        {
        public Button Android_shareButton;
    
        void Start()
        {
            Android_shareButton.onClick.AddListener(Share);
        }
    
            /// <summary>
            /// 安卓原生分享
            /// </summary>
            public void Share()
            {
                #if UNITY_ANDROID && !UNITY_EDITOR
                //定义AndroidJavaClass变量
                AndroidJavaClass UnityPlayer;
                AndroidJavaClass Intent;
                AndroidJavaClass Uri;
                AndroidJavaClass Environment;
    
                //实例化AndroidJavaClass变量
                UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                Intent = new AndroidJavaClass ("android.content.Intent");
                Uri = new AndroidJavaClass ("android.net.Uri");
                Environment = new AndroidJavaClass ("android.os.Environment");
    
                AndroidJavaObject currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
    
                AndroidJavaObject jstr_type = new AndroidJavaObject("java.lang.String", "text/plain");
            //    AndroidJavaObject jstr_content = new AndroidJavaObject("java.lang.String", "https://play.google.com/store/apps/details?id= " + Application.identifier);
                AndroidJavaObject jstr_content = new AndroidJavaObject("java.lang.String", "https://blog.csdn.net/LIQIANGEASTSUN/article/details/78835238");
    
                AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", Intent.GetStatic<AndroidJavaObject>("ACTION_SEND"));
                intent.Call<AndroidJavaObject>("setType", jstr_type);
                intent.Call<AndroidJavaObject>("putExtra", Intent.GetStatic<AndroidJavaObject>("EXTRA_TEXT"), jstr_content);
    
                currentActivity.Call("startActivity", intent);
    
                #endif
            }
        }
    

    相关文章

      网友评论

          本文标题:安卓支付

          本文链接:https://www.haomeiwen.com/subject/xnfxkftx.html