本文整理汇总了C#中UnityEngine.AndroidJavaObject.Call方法的典型用法代码示例。如果您正苦于以下问题:C# AndroidJavaObject.Call方法的具体用法?C# AndroidJavaObject.Call怎么用?C# AndroidJavaObject.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AndroidJavaObject
的用法示例。
在下文中一共展示了AndroidJavaObject.Call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchOBB
public static void FetchOBB()
{
#if UNITY_ANDROID
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", "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();
}
}
#endif
}
示例2: 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;
}
}
}
}
示例3: UpgradeVG
public UpgradeVG(AndroidJavaObject jniUpgradeVG)
: base(jniUpgradeVG)
{
GoodItemId = jniUpgradeVG.Call<string>("getGoodItemId");
NextItemId = jniUpgradeVG.Call<string>("getNextItemId");
PrevItemId = jniUpgradeVG.Call<string>("getPrevItemId");
}
示例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: getDiskFreeSpace
/// <summary>
/// 取得磁盘空间
/// </summary>
/// <param name="path"></param>
/// <returns>-1表示未知。失败时返回0</returns>
public static Int64 getDiskFreeSpace(String path)
{
#if UNITY_STANDALONE_WIN
ulong FreeBytesAvailable;
ulong TotalNumberOfBytes;
ulong TotalNumberOfFreeBytes;
bool success = GetDiskFreeSpaceEx(path,
out FreeBytesAvailable,
out TotalNumberOfBytes,
out TotalNumberOfFreeBytes);
if (!success)
return 0;
return (Int64)TotalNumberOfFreeBytes;
#elif UNITY_ANDROID
AndroidJavaObject statFs = new AndroidJavaObject("android.os.StatFs", path);
return (Int64)statFs.Call<Int32>("getBlockSize") * (Int64)statFs.Call<Int32>("getAvailableBlocks");
#elif UNITY_IOS
ulong TotalNumberOfFreeBytes;
bool success = exp_freeDiskSize(out TotalNumberOfFreeBytes);
if(!success)
return 0;
return (Int64)TotalNumberOfFreeBytes;
#else
return -1;
#endif
}
示例6: 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
}
示例7: PurchasableVirtualItem
protected PurchasableVirtualItem(AndroidJavaObject jniVirtualItem)
: base(jniVirtualItem)
{
SoomlaUtils.LogDebug(TAG, "Trying to create PurchasableVirtualItem with itemId: " +
jniVirtualItem.Call<string>("getItemId"));
using(AndroidJavaObject jniPurchaseType = jniVirtualItem.Call<AndroidJavaObject>("getPurchaseType")) {
System.IntPtr cls = AndroidJNI.FindClass("com/soomla/store/purchaseTypes/PurchaseWithMarket");
if (AndroidJNI.IsInstanceOf(jniPurchaseType.GetRawObject(), cls)) {
using(AndroidJavaObject jniMarketItem = jniPurchaseType.Call<AndroidJavaObject>("getMarketItem")) {
MarketItem mi = new MarketItem(jniMarketItem);
PurchaseType = new PurchaseWithMarket(mi);
}
} else {
cls = AndroidJNI.FindClass("com/soomla/store/purchaseTypes/PurchaseWithVirtualItem");
if (AndroidJNI.IsInstanceOf(jniPurchaseType.GetRawObject(), cls)) {
string itemId = jniPurchaseType.Call<string>("getTargetItemId");
int amount = jniPurchaseType.Call<int>("getAmount");
PurchaseType = new PurchaseWithVirtualItem(itemId, amount);
} else {
SoomlaUtils.LogError(TAG, "Couldn't determine what type of class is the given purchaseType.");
}
}
}
}
示例8: 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;
}
示例9: OpenGallery
public void OpenGallery()
{
#if UNITY_ANDROID
//instantiate the class Intent
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
//instantiate the object Intent
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
//call setAction setting ACTION_SEND as parameter
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_PICK"));
//instantiate the class Uri
//AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
//instantiate the object Uri with the parse of the url's file
//AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "content://media/internal/images/media");
//call putExtra with the uri object of the file
//intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
//set the type of file
intentObject.Call<AndroidJavaObject>("setType", "image/jpeg");
#region [ startActivity(intent); ]
//instantiate the class UnityPlayer
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
//instantiate the object currentActivity
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
//call the activity with our Intent
currentActivity.Call("startActivity", intentObject);
#endregion [ startActivity(intent); ]
#endif
}
示例10: 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
}
示例11: 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();
}
}
}
}
示例12: 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);
}
示例13: showDialog
private void showDialog(string msg)
{
#if UNITY_ANDROID
// Obtain activity
AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic< AndroidJavaObject> ("currentActivity");
// Lets execute the code in the UI thread
activity.Call("runOnUiThread", new AndroidJavaRunnable(() => {
//clear flag
clearflag ();
// Create an AlertDialog.Builder object
AndroidJavaObject alertDialogBuilder = new AndroidJavaObject("android/app/AlertDialog$Builder", activity);
// Call setMessage on the builder
alertDialogBuilder.Call< AndroidJavaObject> ("setMessage", msg);
// Call setCancelable on the builder
alertDialogBuilder.Call< AndroidJavaObject> ("setCancelable", true);
// Call setPositiveButton and set the message along with the listner
// Listner is a proxy class
alertDialogBuilder.Call< AndroidJavaObject> ("setPositiveButton", "Yes", new PositiveButtonListner(this));
// Call setPositiveButton and set the message along with the listner
// Listner is a proxy class
alertDialogBuilder.Call< AndroidJavaObject> ("setNegativeButton", "No", new NegativeButtonListner(this));
// Finally get the dialog instance and show it
AndroidJavaObject dialog = alertDialogBuilder.Call< AndroidJavaObject> ("create");
dialog.Call("show");
}));
#endif
}
示例14: 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);
}
示例15: 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
}