本文整理汇总了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);
}
示例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
}
示例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
}
示例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
}
示例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);
}
示例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;
}
示例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");
}
}
示例8: NativeGetCppVersion
public static void NativeGetCppVersion()
{
#if !UNITY_EDITOR && UNITY_ANDROID
AndroidJavaClass jc = new AndroidJavaClass("com.snow.plugin.NativeBridge");
jc.CallStatic("NativeGetCppVersion");
#endif
}
示例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;
}
示例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
}
示例11: Init
public void Init()
{
#if UNITY_ANDROID
jc = new AndroidJavaClass("unityplugin.phuongnd.com.androidplugin.MainActivity");
Debug.Log("JavaClass -----------------> " + jc);
#endif
}
示例12: DataManager
public DataManager(IntPtr dataManagerPtr, AndroidJavaObject dataManagerJavaObject)
{
innerDataManager = dataManagerPtr;
innerDataManagerJavaObject = dataManagerJavaObject;
if(javaUnityApplicasaDataManager==null)
javaUnityApplicasaDataManager = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaDataManager");
}
示例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);
}
示例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
}
示例15: OnclickButton
// Use this for initialization
public void OnclickButton()
{
using (AndroidJavaClass jc = new AndroidJavaClass("com.example.yoon.newgps.BridgeActivity"))
{
jc.CallStatic("SetToast", "hello world");
}
}