当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.AndroidJavaClass类代码示例

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


AndroidJavaClass类属于UnityEngine命名空间,在下文中一共展示了AndroidJavaClass类的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: 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

示例3: Initialize

		public static void Initialize() {
			SoomlaUtils.LogDebug(TAG, "Initializing CoreEvents and Soomla Core ...");
#if UNITY_ANDROID && !UNITY_EDITOR
			AndroidJNI.PushLocalFrame(100);

			using(AndroidJavaClass jniStoreConfigClass = new AndroidJavaClass("com.soomla.SoomlaConfig")) {
				jniStoreConfigClass.SetStatic("logDebug", CoreSettings.DebugMessages);
			}

			// Initializing SoomlaEventHandler
			using(AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.core.unity.SoomlaEventHandler")) {
				jniEventHandler.CallStatic("initialize");
			}

			// Initializing Soomla Secret
			using(AndroidJavaClass jniSoomlaClass = new AndroidJavaClass("com.soomla.Soomla")) {
				jniSoomlaClass.CallStatic("initialize", CoreSettings.SoomlaSecret);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
			soomlaCore_Init(CoreSettings.SoomlaSecret, CoreSettings.DebugMessages);
#elif UNITY_WP8 && !UNITY_EDITOR
            SoomlaWpCore.SoomlaConfig.logDebug = CoreSettings.DebugMessages;
            SoomlaWpCore.Soomla.initialize(CoreSettings.SoomlaSecret);
            BusProvider.Instance.Register(CoreEvents.instance);
#endif

        }
开发者ID:nickhester,项目名称:SocialNetwork,代码行数:28,代码来源:CoreEvents.cs

示例4: 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

示例5: _setFastestDurationMillis

		protected override void _setFastestDurationMillis(Level level, long duration) {
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniLevelStorage = new AndroidJavaClass("com.soomla.levelup.data.LevelStorage")) {
				jniLevelStorage.CallStatic("setFastestDurationMillis", level.ID, duration);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
开发者ID:Ratel13,项目名称:unity3d-levelup,代码行数:7,代码来源:LevelStorageAndroid.cs

示例6: CheckReward

    public static string CheckReward()
    {
        #if UNITY_IPHONE && !UNITY_EDITOR
        return UnityShimOAD_CheckReward ();
        #endif
        #if UNITY_ANDROID
        AndroidJavaClass oadClass = new AndroidJavaClass("com.openadadapter.OpenAdAdapter");
        if (oadClass != null){

            bool b1 = oadClass.CallStatic<bool>("hasReward");

            if(!b1){
                return null;
            }

            AndroidJavaClass rwdClass = new AndroidJavaClass("com.openadadapter.Reward");
            if(rwdClass != null){
                AndroidJavaObject r1 = oadClass.CallStatic<AndroidJavaObject>("fetchReward");
                if (r1.GetRawObject().ToInt32() == 0){
                    return null;
                }
                //		float height = oadClass.CallStatic<float>("getBannerHeightInPoints");
                float amount = r1.Call<float>("getAmount");
                string network = r1.Call<string>("getNetwork");
                string currency = r1.Call<string>("getCurrency");

                return "amount\t" + amount + "\nnetwork\t" + network + "\ncurrency\t" + currency;
            }
        }
        #endif
        return null;
    }
开发者ID:OpenAdAdapter,项目名称:OAD-Unity-src,代码行数:32,代码来源:OpenAdAdapter.cs

示例7: 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

示例8: NativeGetCppVersion

 public static void NativeGetCppVersion()
 {
     #if !UNITY_EDITOR && UNITY_ANDROID
     AndroidJavaClass jc = new AndroidJavaClass("com.snow.plugin.NativeBridge");
     jc.CallStatic("NativeGetCppVersion");
     #endif
 }
开发者ID:toxly,项目名称:unity-app,代码行数:7,代码来源:PlatformTools.cs

示例9: ForceLoadLowLevelBinary

			static public bool ForceLoadLowLevelBinary()
			{
				// This is a hack that forces Android to load the .so libraries in the correct order
#if UNITY_ANDROID && !UNITY_EDITOR
				FMOD.Studio.UnityUtil.Log("loading binaries: " + FMOD.Studio.STUDIO_VERSION.dll + " and " + FMOD.VERSION.dll);
				AndroidJavaClass jSystem = new AndroidJavaClass("java.lang.System");
				jSystem.CallStatic("loadLibrary", FMOD.VERSION.dll);
				jSystem.CallStatic("loadLibrary", FMOD.Studio.STUDIO_VERSION.dll);
#endif

				// Hack: force the low level binary to be loaded before accessing Studio API
#if !UNITY_IPHONE || UNITY_EDITOR
				FMOD.Studio.UnityUtil.Log("Attempting to call Memory_GetStats");
				int temp1, temp2;
				if (!ERRCHECK(FMOD.Memory.GetStats(out temp1, out temp2)))
				{
					FMOD.Studio.UnityUtil.LogError("Memory_GetStats returned an error");
					return false;
				}
		
				FMOD.Studio.UnityUtil.Log("Calling Memory_GetStats succeeded!");
#endif
		
				return true;
			}
开发者ID:Backman,项目名称:Hellbound,代码行数:25,代码来源:FMOD_StudioSystem.cs

示例10: Initialize

		public static void Initialize() {
			SoomlaUtils.LogDebug (TAG, "SOOMLA/UNITY Initializing Highway");
#if UNITY_ANDROID && !UNITY_EDITOR
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniGrowHighwayClass = new AndroidJavaClass("com.soomla.highway.GrowHighway")) {

				AndroidJavaObject jniGrowHighwayInstance = jniGrowHighwayClass.CallStatic<AndroidJavaObject>("getInstance");
				jniGrowHighwayInstance.Call("initialize", HighwaySettings.HighwayGameKey, HighwaySettings.HighwayEnvKey);

				// Uncomment this and change the URL for testing
//				using(AndroidJavaClass jniConfigClass = new AndroidJavaClass("com.soomla.highway.HighwayConfig")) {
//					AndroidJavaObject jniConfigObject = jniConfigClass.CallStatic<AndroidJavaObject>("getInstance");
//					jniConfigObject.Call("setUrls", "http://example.com", "http://example.com");
//				}

				jniGrowHighwayInstance.Call("start");
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
#elif UNITY_IOS && !UNITY_EDITOR
			growHighway_initialize(HighwaySettings.HighwayGameKey, HighwaySettings.HighwayEnvKey);

			// Uncomment this and change the URL for testing
//			growHighway_setHighwayUrl("http://example.com");
//			growHighway_setServicesUrl("http://example.com");

			growHighway_start();
#else
			SoomlaUtils.LogError(TAG, "Highway only works on Android or iOS devices !");
		//	UnityEditor.EditorApplication.isPlaying = false;
#endif
		}
开发者ID:Bakiet,项目名称:UnityZombieCross,代码行数:31,代码来源:GrowHighway.cs

示例11: Init

    public void Init()
    {
#if UNITY_ANDROID
        jc = new AndroidJavaClass("unityplugin.phuongnd.com.androidplugin.MainActivity");
        Debug.Log("JavaClass -----------------> " + jc);
#endif
    }
开发者ID:ndp1100,项目名称:ndp1100.github.io,代码行数:7,代码来源:EJSDKManager.cs

示例12: 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

示例13: Enable

		public static void Enable(bool enabled){
			AndroidJavaObject _plugin;
			using(var pluginClass = new AndroidJavaClass("com.zendesk.unity.ZDK_Plugin")){
				_plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
			}
			_plugin.Call("enableLogger", enabled);
		}
开发者ID:Jannizzle,项目名称:ZENDESK,代码行数:7,代码来源:ZDKLogger.cs

示例14: SendEmail

		public static void SendEmail(Email email)
		{
#if UNITY_IOS && !UNITY_EDITOR
			_opencodingConsoleBeginEmail(email.ToAddress, email.Subject, email.Message, email.IsHTML);
			foreach (var attachment in email.Attachments)
			{
				_opencodingConsoleAddAttachment(attachment.Data, attachment.Data.Length, attachment.MimeType, attachment.Filename);
			}
			_opencodingConsoleFinishEmail();
#elif UNITY_ANDROID && !UNITY_EDITOR
			AndroidJavaClass androidEmailClass = new AndroidJavaClass("net.opencoding.console.Email");
			
			androidEmailClass.CallStatic("beginEmail", email.ToAddress, email.Subject, email.Message, email.IsHTML);
			var emailAttachmentsDirectory = Path.Combine(Application.temporaryCachePath, "EmailAttachments");
			Directory.CreateDirectory(emailAttachmentsDirectory);
			foreach (var attachment in email.Attachments)
			{
				var attachmentPath = Path.Combine(emailAttachmentsDirectory, attachment.Filename);
				File.WriteAllBytes(attachmentPath, attachment.Data);
				androidEmailClass.CallStatic("addAttachment", attachmentPath);
			}

			androidEmailClass.CallStatic("finishEmail");
#else
			throw new InvalidOperationException("Emailing is not supported on this platform. Please contact [email protected] and I'll do my best to support it!");
#endif
		}
开发者ID:smclallen,项目名称:Galactic_Parcel_Service,代码行数:27,代码来源:NativeMethods.cs

示例15: OnclickButton

	// Use this for initialization
	public void OnclickButton()
    {
        using (AndroidJavaClass jc = new AndroidJavaClass("com.example.yoon.newgps.BridgeActivity"))
        {
            jc.CallStatic("SetToast", "hello world");
        }
    }
开发者ID:YoonDaewon,项目名称:cash-walk,代码行数:8,代码来源:Plugin.cs


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