Only C#안드로이드 plugin 작업없이 순전히 AndroidJavaObject 클래스를 활용하여C# 으로만 실행하여 처리할 수 있다.
설치되어 있는 특정 패키지를 찾아서 실행시키는 방법.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ClickBtn() | |
{ | |
string packageName = "com.yourcompany.packagename"; | |
bool fail = false; | |
#if UNITY_ANDROID && !UNITY_EDITOR | |
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); | |
AndroidJavaObject intent = jo.Call<AndroidJavaObject>("getPackageManager"); | |
try{ | |
intent.Call<AndroidJavaObject>( "getLaunchIntentForPackage", packageName); | |
} | |
catch( System.Exception e ) { | |
fail = true; | |
} | |
if( fail ) | |
{ | |
Debug.Log( "Could not find App" ); | |
} | |
else | |
{ | |
jo.Call("startActivity", intent); | |
} | |
#endif | |
} |
댓글 없음:
댓글 쓰기