本文整理汇总了C#中UnityEngine.AndroidJavaClass.GetStatic方法的典型用法代码示例。如果您正苦于以下问题:C# AndroidJavaClass.GetStatic方法的具体用法?C# AndroidJavaClass.GetStatic怎么用?C# AndroidJavaClass.GetStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AndroidJavaClass
的用法示例。
在下文中一共展示了AndroidJavaClass.GetStatic方法的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: OnGUI
void OnGUI()
{
if (GUI.Button(new Rect(0, 0, 200, 200), "Login"))
{
// to get the activity
var androidJC = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var jo = androidJC.GetStatic<AndroidJavaObject>("currentActivity");
// Accessing the class to call a static method on it
var jc = new AndroidJavaClass("com.example.yoon.lib.StartActivity");
// Calling a Call method to which the current activity is passed
jc.CallStatic("Call", jo);
}
if (GUI.Button(new Rect(600, 600, 200, 200), "Login"))
{
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject app = activity.Call<AndroidJavaObject>("getApplicationContext");
imei = SystemInfo.deviceUniqueIdentifier;
bg = new AndroidJavaClass("com.example.yoon.lib.StartActivity");
activity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
{
bg.CallStatic("callMap", app, imei);
}));
}
}
示例3: ShareAndroidText
IEnumerator ShareAndroidText ()
{
yield return new WaitForEndOfFrame ();
#if UNITY_ANDROID
byte[] bytes = MyImage.EncodeToPNG();
string path = Application.persistentDataPath + "/MyImage.png";
File.WriteAllBytes(path, bytes);
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
intentObject.Call<AndroidJavaObject>("setType", "image/*");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "Text Sharing ");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TITLE"), "Text Sharing ");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), "Text Sharing Android Demo");
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject fileObject = new AndroidJavaObject("java.io.File", path);// Set Image Path Here
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("fromFile", fileObject);
// string uriPath = uriObject.Call<string>("getPath");
bool fileExist = fileObject.Call<bool>("exists");
Debug.Log("File exist : " + fileExist);
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivity", intentObject);
#endif
}
示例4: FileStream
IEnumerator ShareScreenshotInterface.ShareScreenshot(byte[] screenshot, bool isProcessing, string shareText, string gameLink, string subject)
{
isProcessing = true;
string destination = Path.Combine(Application.persistentDataPath, "Screenshot.png");
FileStream fs = new FileStream(destination, FileMode.OpenOrCreate);
BinaryWriter ww = new BinaryWriter(fs);
ww.Write(screenshot);
ww.Close();
fs.Close();
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"), shareText + gameLink);
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
intentObject.Call<AndroidJavaObject>("setType", "image/png");
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivity", intentObject);
isProcessing = false;
yield return new WaitForSeconds(1);
}
示例5: ShareCoroutineAndroid
private IEnumerator ShareCoroutineAndroid(string destination, string fullDestination)
{
#if UNITY_ANDROID
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaClass fileClass = new AndroidJavaClass("java.io.File");
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + fullDestination);
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
intentObject.Call<AndroidJavaObject>("setType", "image/jpeg");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), "Check out my streak in " + MessageBook.AppName);
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
// display the chooser
AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Choose sharing method");
currentActivity.Call("startActivity", jChooser);
#endif
yield return null;
}
示例6: 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
}
示例7: GetApiClient
/// <summary>Gets the Google API client Java object.</summary>
/// <returns>The API client associated with the current Unity app.</returns>
/// <param name="serverClientID">The OAuth 2.0 client ID for a backend server.</param>
public AndroidJavaObject GetApiClient(bool getServerAuthCode = false,
string serverClientID = null)
{
Debug.Log("Calling GetApiClient....");
using (var currentActivity = GetActivity())
{
using (AndroidJavaClass jc_plus = new AndroidJavaClass("com.google.android.gms.plus.Plus"))
{
using (AndroidJavaObject jc_builder = new AndroidJavaObject("com.google.android.gms.common.api.GoogleApiClient$Builder", currentActivity))
{
jc_builder.Call<AndroidJavaObject>("addApi", jc_plus.GetStatic<AndroidJavaObject>("API"));
jc_builder.Call<AndroidJavaObject>("addScope", jc_plus.GetStatic<AndroidJavaObject>("SCOPE_PLUS_LOGIN"));
if (getServerAuthCode)
{
jc_builder.Call<AndroidJavaObject>("requestServerAuthCode", serverClientID, jc_builder);
}
AndroidJavaObject client = jc_builder.Call<AndroidJavaObject>("build");
client.Call("connect");
// limit spinning to 100, to minimize blocking when not
// working as expected.
// TODO: Make this a callback.
int ct = 100;
while ((!client.Call<bool>("isConnected")) && (ct-- != 0))
{
System.Threading.Thread.Sleep(100);
}
Debug.Log("Done GetApiClient is " + client);
return client;
}
}
}
}
示例8: ShareScreenshot
private IEnumerator ShareScreenshot()
{
isProcessing = true;
yield return new WaitForEndOfFrame();
Texture2D screenTexture = new Texture2D(1080, 1080, TextureFormat.RGB24, true);
screenTexture.Apply();
if (!Application.isEditor)
{
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string> ("ACTION_SEND"));
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), shareText + gameLink);
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), subject);
intentObject.Call<AndroidJavaObject>("setType", "text/plain");
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivity", intentObject);
}
isProcessing = false;
}
示例9: 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
}
示例10: 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
}
示例11: 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");
}
}
示例12: ShareScreenshot
public IEnumerator ShareScreenshot()
{
isProcessing = true;
// wait for graphics to render
yield return new WaitForEndOfFrame();
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO
// create the texture
Texture2D screenTexture = new Texture2D(Screen.width, Screen.height,TextureFormat.RGB24,true);
// put buffer into texture
screenTexture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height),0,0);
// apply
screenTexture.Apply();
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO
byte[] dataToSave = screenTexture.EncodeToPNG();
string destination = Path.Combine(Application.persistentDataPath,System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png");
File.WriteAllBytes(destination, dataToSave);
if(!Application.isEditor)
{
// 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 WITHOUT chooser:
currentActivity.Call("startActivity", intentObject);
// option two WITH chooser:
//AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "HALUATKO JAKAA KÄNNIT?");
//currentActivity.Call("startActivity", jChooser);
// block to open the file and share it ------------END
}
isProcessing = false;
}
示例13: OnClickRate
public void OnClickRate()
{
GPlusPlatform.Instance.AnalyticsTrackEvent("InGame", "Options", "Rate", 0);
//Application.OpenURL ("market://details?id=com.banegole.marinegrowing");
AndroidJavaClass intentClass = new AndroidJavaClass ("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject ("android.content.Intent");
intentObject.Call<AndroidJavaObject> ("setAction", intentClass.GetStatic<string> ("ACTION_SEND"));
intentObject.Call<AndroidJavaObject> ("setType", "text/plain");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "Tap Marine");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), "https://play.google.com/store/apps/details?id="+Const.PackageName);
AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity");
currentActivity.Call ("startActivity", intentObject);
}
示例14: OnGUI
void OnGUI()
{
try
{
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
i = jo.Call<int>("Max", new object[] { 10, 20 });
GUILayout.Label(tex);
GUILayout.Label(i.ToString());
if (GUILayout.Button("保存图片", GUILayout.Width(64), GUILayout.Height(64)))
{
Debug.Log(tex.format);
tex.SaveToAlbum();
}
if (GUILayout.Button("demo", GUILayout.Width(64), GUILayout.Height(64)))
{
Application.LoadLevel(1);
}
if (GUI.Button(new Rect(Screen.width / 2 - 20, Screen.height / 2 + 20, 100, 40), "点击震动"))
{
jo.Call("ClickShake");
}
}
catch (System.Exception ex)
{
Debug.LogError("error:" + ex.StackTrace);
Debug.LogError("error:" + ex.Source);
Debug.LogError("error:" + ex.Message);
}
}
示例15: 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;
}