• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.AndroidJavaObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.AndroidJavaObject的典型用法代码示例。如果您正苦于以下问题:C# AndroidJavaObject类的具体用法?C# AndroidJavaObject怎么用?C# AndroidJavaObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AndroidJavaObject类属于UnityEngine命名空间,在下文中一共展示了AndroidJavaObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Init

        public static void Init()
        {
            AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            if (jc == null)
            return;

            AndroidJavaObject joactivety = jc.GetStatic<AndroidJavaObject>("currentActivity");
            if (joactivety == null)
            return;
            AndroidJavaObject context = joactivety.Call<AndroidJavaObject>("getApplicationContext");
            // 初始化HttpDns
            AndroidJavaObject joDnsClass = new AndroidJavaObject("com.tencent.msdk.dns.MSDKDnsResolver");
            Debug.Log(" WGGetHostByName ===========" + joDnsClass);
            if (joDnsClass == null)
            return;
            m_dnsJo = joDnsClass.CallStatic<AndroidJavaObject>("getInstance");
            Debug.Log(" WGGetHostByName ===========" + m_dnsJo);
            if (m_dnsJo == null)
            return;
            m_dnsJo.Call("init", context);
            // 初始化灯塔
            AndroidJavaObject joBeaconClass = new AndroidJavaObject("com.tencent.beacon.event.UserAction");
            if (joBeaconClass == null)
            return;
            m_dnsJo.Call("initUserAction", context);
        }
开发者ID:XClouded,项目名称:httpdns-android-sdk,代码行数:26,代码来源:HttpDns.cs


示例2: ShareImage

    // Use this for initialization
    public void ShareImage()
    {
        #if UNITY_ANDROID

            Application.CaptureScreenshot("/Screenshot.png");

            string destination = Application.persistentDataPath + "/Screenshot.png";
            Debug.Log (destination);
            // block to open the file and share it ------------START
            AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
            AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
            intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
            AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
            AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse","file://" + destination);
            intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
            //intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), "testo");
            //intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "SUBJECT");
            intentObject.Call<AndroidJavaObject>("setType", "image/jpeg");
            AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");

            // option one:
            currentActivity.Call("startActivity", intentObject);
        #endif
    }
开发者ID:YuvalFeldman,项目名称:JetCat,代码行数:26,代码来源:LoseScreen.cs


示例3: shareText

    public void shareText()
    {
        //execute the below lines if being run on a Android device
    #if UNITY_ANDROID
        body = "Faltan " + RolCountdownController.daysRemaining + " días, " + RolCountdownController.hoursRemaining + " horas y " + RolCountdownController.minutesRemaining + " minutos para las próxima roleada!";

        //Refernece of AndroidJavaClass class for intent
        AndroidJavaClass intentClass = new AndroidJavaClass ("android.content.Intent");
        //Refernece of AndroidJavaObject class for intent
        AndroidJavaObject intentObject = new AndroidJavaObject ("android.content.Intent");
        //call setAction method of the Intent object created
        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
        //set the type of sharing that is happening
        intentObject.Call<AndroidJavaObject>("setType", "text/plain");
        //add data to be passed to the other activity i.e., the data to be sent
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), body);
        //get the current activity
        AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
        //start the activity by sending the intent data
        currentActivity.Call ("startActivity", intentObject);
    #endif

    }
开发者ID:pravusjif,项目名称:PravusUnityTests,代码行数:25,代码来源:ShareApp.cs


示例4: Chat

 public Chat(IntPtr chatPtr, AndroidJavaObject chatJavaObject)
 {
     innerChat = chatPtr;
     innerChatJavaObject = chatJavaObject;
     if(javaUnityApplicasaChat==null)
         javaUnityApplicasaChat = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaChat");
 }
开发者ID:Applicasa,项目名称:Sample-App-Unity,代码行数:7,代码来源:Chat.cs


示例5: Invoke

 /// <summary>
 ///   <para>Called by the java vm whenever a method is invoked on the java proxy interface. You can override this to run special code on method invokation, or you can leave the implementation as is, and leave the default behavior which is to look for c# methods matching the signature of the java method.</para>
 /// </summary>
 /// <param name="methodName">Name of the invoked java method.</param>
 /// <param name="args">Arguments passed from the java vm - converted into AndroidJavaObject, AndroidJavaClass or a primitive.</param>
 /// <param name="javaArgs">Arguments passed from the java vm - all objects are represented by AndroidJavaObject, int for instance is represented by a java.lang.Integer object.</param>
 public virtual AndroidJavaObject Invoke(string methodName, AndroidJavaObject[] javaArgs)
 {
   object[] args = new object[javaArgs.Length];
   for (int index = 0; index < javaArgs.Length; ++index)
     args[index] = _AndroidJNIHelper.Unbox(javaArgs[index]);
   return this.Invoke(methodName, args);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:13,代码来源:AndroidJavaProxy.cs


示例6: OpenIAB_Android

        static OpenIAB_Android()
        {
            if (Application.platform != RuntimePlatform.Android)
            {
                STORE_GOOGLE = "STORE_GOOGLE";
                STORE_AMAZON = "STORE_AMAZON";
                STORE_SAMSUNG = "STORE_SAMSUNG";
                STORE_NOKIA = "STORE_NOKIA";
                STORE_YANDEX = "STORE_YANDEX";
                return;
            }

            AndroidJNI.AttachCurrentThread();

            // Find the plugin instance
            using (var pluginClass = new AndroidJavaClass("org.onepf.openiab.UnityPlugin"))
            {
                _plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
                STORE_GOOGLE = pluginClass.GetStatic<string>("STORE_GOOGLE");
                STORE_AMAZON = pluginClass.GetStatic<string>("STORE_AMAZON");
                STORE_SAMSUNG = pluginClass.GetStatic<string>("STORE_SAMSUNG");
                STORE_NOKIA = pluginClass.GetStatic<string>("STORE_NOKIA");
                STORE_YANDEX = pluginClass.GetStatic<string>("STORE_YANDEX");
            }
        }
开发者ID:Ixxy,项目名称:OpenIAB-Unity-Plugin,代码行数:25,代码来源:OpenIAB_Android.cs


示例7: start

        public void start(AdjustConfig adjustConfig)
        {
            AndroidJavaObject ajoEnvironment = adjustConfig.environment == AdjustEnvironment.Sandbox ?
                new AndroidJavaClass ("com.adjust.sdk.AdjustConfig").GetStatic<AndroidJavaObject> ("ENVIRONMENT_SANDBOX") :
                    new AndroidJavaClass ("com.adjust.sdk.AdjustConfig").GetStatic<AndroidJavaObject> ("ENVIRONMENT_PRODUCTION");

            AndroidJavaObject ajoAdjustConfig = new AndroidJavaObject ("com.adjust.sdk.AdjustConfig", ajoCurrentActivity, adjustConfig.appToken, ajoEnvironment);

            if (adjustConfig.logLevel != null) {
                AndroidJavaObject ajoLogLevel = new AndroidJavaClass ("com.adjust.sdk.LogLevel").GetStatic<AndroidJavaObject> (adjustConfig.logLevel.ToString().ToUpper());

                if (ajoLogLevel != null) {
                    ajoAdjustConfig.Call ("setLogLevel", ajoLogLevel);
                }
            }

            if (adjustConfig.attributionChangedDelegate != null) {
                onAttributionChangedListener = new AttributionChangeListener (adjustConfig.attributionChangedDelegate);
                ajoAdjustConfig.Call ("setOnAttributionChangedListener", onAttributionChangedListener);
            }

            ajoAdjustConfig.Call ("setSdkPrefix", adjustConfig.sdkPrefix);

            ajcAdjust.CallStatic ("onCreate", ajoAdjustConfig);
        }
开发者ID:tengontheway,项目名称:unity_sdk,代码行数:25,代码来源:AdjustAndroid.cs


示例8: GameV

 public GameV(IntPtr gameVPtr, AndroidJavaObject gameVJavaObject)
 {
     innerGameV = gameVPtr;
     innerGameVJavaObject = gameVJavaObject;
     if(javaUnityApplicasaGameV==null)
         javaUnityApplicasaGameV = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaGameV");
 }
开发者ID:Applicasa,项目名称:Sample-App-Unity,代码行数:7,代码来源:GameV.cs


示例9: Density

 static Density()
 {
     Value = 1.0f;
     #if UNITY_ANDROID
     using (
         AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
         metricsClass = new AndroidJavaClass("android.util.DisplayMetrics")
         ) {
         using (
             AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
             activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
             windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
             displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")
             ) {
             displayInstance.Call ("getMetrics", metricsInstance);
             Value = metricsInstance.Get<float> ("density");
         }
     }
     #endif
     #if UNITY_IPHONE
     if (Application.platform != RuntimePlatform.OSXEditor) {
         Value = IOSDensity_ ();
     }
     #endif
 }
开发者ID:polishedsolid,项目名称:Unity,代码行数:25,代码来源:Density.cs


示例10: GetStatusCode

 // Gets the status code from a Result object
 public static int GetStatusCode(AndroidJavaObject result) {
     if (result == null) {
         return -1;
     }
     AndroidJavaObject status = result.Call<AndroidJavaObject>("getStatus");
     return status.Call<int>("getStatusCode");
 }
开发者ID:82joong,项目名称:play-games-plugin-for-unity,代码行数:8,代码来源:JavaUtil.cs


示例11: Query

 public Query(IntPtr queryPtr, AndroidJavaObject queryJavaObject)
 {
     innerQuery = queryPtr;
     innerQueryJavaObject = queryJavaObject;
     if(javaUnityApplicasaQuery==null)
         javaUnityApplicasaQuery = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaQuery");
 }
开发者ID:OrLavee,项目名称:Sample-App-Unity,代码行数:7,代码来源:Query.cs


示例12: Start

	// Use this for initialization
	void Start () {
		AndroidJavaClass majcUnityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		AndroidJavaObject majoDivePluginInstance = majcUnityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
		metricsClass= new AndroidJavaClass("android.util.DisplayMetrics");
		metricsInstance= new AndroidJavaObject("android.util.DisplayMetrics");
		windowManagerInstance=majoDivePluginInstance.Call<AndroidJavaObject>("getWindowManager");
		displayInstance=windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay");
		
		displayInstance.Call("getMetrics",metricsInstance);
		
		density=metricsInstance.Get<float>("density");
		densitydpi=metricsInstance.Get<int> ("densityDpi");
		vpixels=metricsInstance.Get<int>("heightPixels");
		vpixels=Screen.height;
		hpixels=metricsInstance.Get<int>("widthPixels");
		//hpixels=displayInstance.Call<int>("getWidth");
		hpixels=Screen.width;
		scaledDensity=metricsInstance.Get<float>("scaledDensity");
		xdpi=metricsInstance.Get<float>("xdpi");
		ydpi=metricsInstance.Get<float>("ydpi");
		xmm=hpixels/xdpi/0.0393701f;
		ymm=vpixels/ydpi/0.0393701f;
		
		
		hpixels=Screen.width;
		vpixels=Screen.height;
		xmm=hpixels/xdpi/0.0393701f;
		ymm=vpixels/ydpi/0.0393701f;
		mmdist=xmm/2;
	}
开发者ID:Gkxd,项目名称:ProjectCodetta,代码行数:31,代码来源:NaturalOrientation.cs


示例13: Initialize

    // Initializes the class and bind with the Android platform via JNI.
    // You must always call this once whenever you needed this technology for
    // your project.
    public static void Initialize( int maxStreams )
    {
        #if UNITY_ANDROID && !UNITY_EDITOR
        m_unityActivityClass = new AndroidJavaClass( "com.unity3d.player.UnityPlayer" );
        if( m_unityActivityClass == null )
        {
            DebugUtil.LogError( "AdnAudioBridge: Cannot bind to UnityPlayer class!" );
            return;
        }

        m_activityContext = m_unityActivityClass.GetStatic< AndroidJavaObject >( "currentActivity" );
        if( m_activityContext == null )
        {
            DebugUtil.LogError( "AdnAudioBridge: Cannot find UnityPlayer instance!" );
            return;
        }

        m_soundObject = new AndroidJavaObject( "net.andreivictor.uqsl.adnaudiobridge.AdnAudioBridge", maxStreams, 128, m_activityContext );
        if( m_soundObject == null )
        {
            DebugUtil.LogError( "AdnAudioBridge: Failed to bind with AdnAudioBridge." );
            return;
        }
        #endif //UNITY_ANDROID && !UNITY_EDITOR
    }
开发者ID:elmachotroso,项目名称:uqsl,代码行数:28,代码来源:AdnAudioBridge.cs


示例14: IsLocked

    public static int IsLocked()
    {
        try
        {
            using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
            }

            using (
                AndroidJavaClass pluginClass =
                    new AndroidJavaClass("com.dualcorstudios.unityscreenpin.DCSAndroidToolkit"))
            {
                if (pluginClass != null)
                {
                    DCSToolkit = pluginClass.CallStatic<AndroidJavaObject>("instance");
                    DCSToolkit.Call("setContext", activityContext);
                    return activityContext.Call<int>("runOnUiThread",
                        new AndroidJavaRunnable(() => { DCSToolkit.Call("isLocked"); }));
                }
            }
        }
        catch (AndroidJavaException e)
        {
            Debug.Log(e.Message);
            Debug.Log(e.StackTrace);
        }
        return 1;
    }
开发者ID:acorrow,项目名称:ToddlerPop,代码行数:29,代码来源:ScreenPin.cs


示例15: OnGUI

    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 200, 100, 30), "Start")){
            loadBytes();

            Application.LoadLevel("GameMenu");
        }

        if(GUI.Button(new Rect(10, 300, 100, 30), "Update")){
            using (AndroidJavaClass unity_player = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
            {
                AndroidJavaObject current_activity = unity_player.GetStatic<AndroidJavaObject>("currentActivity");

                AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent",
                                                                current_activity,
                                                                new AndroidJavaClass("com.unity3d.plugin.downloader.UnityDownloaderActivity"));

                int Intent_FLAG_ACTIVITY_NO_ANIMATION = 0x10000;
                intent.Call<AndroidJavaObject>("addFlags", Intent_FLAG_ACTIVITY_NO_ANIMATION);
                intent.Call<AndroidJavaObject>("putExtra", "name", "Downloading...");

        //				intent.Call<AndroidJavaObject>("putExtra", "unityplayer.Activity",
        //															current_activity.Call<AndroidJavaObject>("getClass").Call<string>("getName"));
                current_activity.Call("startActivity", intent);

                if (AndroidJNI.ExceptionOccurred() != System.IntPtr.Zero)
                {
                    Debug.LogError("Exception occurred while attempting to start DownloaderActivity - is the AndroidManifest.xml incorrect?");
                    AndroidJNI.ExceptionDescribe();
                    AndroidJNI.ExceptionClear();
                }
            }
        }
    }
开发者ID:lite,项目名称:DthUpdate,代码行数:34,代码来源:GameLoader.cs


示例16: HideNavigationBar

	void HideNavigationBar()
	{

		lock(this)
		{
			using(javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
			{
				unityActivity = javaClass.GetStatic<AndroidJavaObject>("currentActivity");
			}
			
			if(unityActivity == null)
			{
				return;
			}
			
			using(javaClass = new AndroidJavaClass("com.rak24.androidimmersivemode.Main"))
			{
				if(javaClass == null)
				{
					return;
				}
				else
				{
					javaObj = javaClass.CallStatic<AndroidJavaObject>("instance");
					if(javaObj == null)
						return;
					unityActivity.Call("runOnUiThread",new AndroidJavaRunnable(() => 
					                                                           {
						javaObj.Call("EnableImmersiveMode", unityActivity);
					}));
				}
			}
		}
	}
开发者ID:coderlazy,项目名称:kloserbsb,代码行数:34,代码来源:ImmersiveModeEnabler.cs


示例17: graphRequest

    // Calls a custom Graph API method with the key/value pairs in the Dictionary.  Pass in a null dictionary if no parameters are needed.
    public static void graphRequest( string graphPath, string httpMethod, Dictionary<string,string> parameters )
    {
        if( Application.platform != RuntimePlatform.Android )
            return;

        // load up the Bundle
        using( var bundle = new AndroidJavaObject( "android.os.Bundle" ) )
        {
            var putStringMethod = AndroidJNI.GetMethodID( bundle.GetRawClass(), "putString", "(Ljava/lang/String;Ljava/lang/String;)V" );
            var args = new object[2];

            // add all our dictionary elements into the Bundle
            if( parameters != null )
            {
                foreach( var kv in parameters  )
                {
                    args[0] = new AndroidJavaObject( "java.lang.String", kv.Key );
                    args[1] = new AndroidJavaObject( "java.lang.String", kv.Value );
                    AndroidJNI.CallObjectMethod( bundle.GetRawObject(), putStringMethod, AndroidJNIHelper.CreateJNIArgArray( args ) );
                }
            }

            // call off to java land
            _facebookPlugin.Call( "graphRequest", graphPath, httpMethod, bundle );
        }
    }
开发者ID:simmmis,项目名称:Kill-Red,代码行数:27,代码来源:FacebookAndroid.cs


示例18: Share

    public void Share(string shareText, string imagePath, string url, string subject = "")
    {
        #if UNITY_ANDROID
        AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
        AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");

        intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
        AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + imagePath);
        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
        intentObject.Call<AndroidJavaObject>("setType", "image/png");

        intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), shareText);

        AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");

        AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, subject);
        currentActivity.Call("startActivity", jChooser);
        #elif UNITY_IOS
        CallSocialShareAdvanced(shareText, subject, url, imagePath);
        #else
        Debug.Log("No sharing set up for this platform.");
        #endif
    }
开发者ID:sebit0nic,项目名称:Sunday-Driver,代码行数:25,代码来源:ShareImageCanvas.cs


示例19: Awake

	void Awake () {
		AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		this.androidJavaObject = ajc.GetStatic<AndroidJavaObject>("currentActivity");
        is_called_startFlag = false;
        recieve_from_Gear_MSG = "";		
		manager.is_gameOver = false;
	}
开发者ID:KimDongWan,项目名称:Miseng,代码行数:7,代码来源:PluginTest.cs


示例20: DataManager

 public DataManager(IntPtr dataManagerPtr, AndroidJavaObject dataManagerJavaObject)
 {
     innerDataManager = dataManagerPtr;
     innerDataManagerJavaObject = dataManagerJavaObject;
     if(javaUnityApplicasaDataManager==null)
         javaUnityApplicasaDataManager = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaDataManager");
 }
开发者ID:Applicasa,项目名称:Sample-App-Unity,代码行数:7,代码来源:DataManager.cs



注:本文中的UnityEngine.AndroidJavaObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.Animation类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.AndroidJavaClass类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap