當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.AndroidJavaObject類代碼示例

本文整理匯總了C#中UnityEngine.AndroidJavaObject的典型用法代碼示例。如果您正苦於以下問題:C# AndroidJavaObject類的具體用法?C# AndroidJavaObject怎麽用?C# AndroidJavaObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AndroidJavaObject類屬於UnityEngine命名空間,在下文中一共展示了AndroidJavaObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的UnityEngine.AndroidJavaObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。