Version: 5.4 (switch to 5.5b)
言語English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

AndroidJavaObject.Call

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

マニュアルに切り替える
public function Call(methodName: string, params args: object[]): void;
public void Call(string methodName, params object[] args);

Parameters

methodName 呼び出する特定のメソッド名
args メソッドに渡す引数の配列

Description

static でない Java メソッドを呼び出します

戻り値のほうが 'void' のメソッドを呼び出すには通常のメソッドを使用します。

	// Create a android.content.res.Configuration object and call setToDefaults.
	function Start() {
		var jo = new AndroidJavaObject("android.content.res.Configuration");
		jo.Call("setToDefaults");
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { AndroidJavaObject jo = new AndroidJavaObject("android.content.res.Configuration"); jo.Call("setToDefaults"); } }

public function Call(methodName: string, params args: object[]): ReturnType;
public ReturnType Call(string methodName, params object[] args);

Parameters

methodName 呼び出する特定のメソッド名
args メソッドに渡す引数の配列

Description

オブジェクト上の Java メソッドを呼び出します

戻り値の型が void でないメソッドを呼び出す場合はジェネリックメソッドを使用します。

	// Create a java.lang.String object holding the string "some string",
	// and retrieve it's hash code.
	function Start() {
		var jo = new AndroidJavaObject("java.lang.String", "some string");
		var hash = jo.Call.<int>("hashCode");
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { AndroidJavaObject jo = new AndroidJavaObject("java.lang.String", "some string"); int hash = jo.Call<int>("hashCode"); } }