1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public void ClickLaunchApp()
    {
        bool fail = false;
        string bundleId = "com.company.appName"; // put your app bundle id
        AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
        AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
 
        AndroidJavaObject launchIntent = null;
 
        launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
 
        if (launchIntent == null)
        {
            fail = true;
        }
 
        if (fail)
        { //open app in store
            Application.OpenURL("market://details?id=" + bundleId);
        }
        else //open the app
        {
            ca.Call("startActivity", launchIntent);
        }
        up.Dispose();
        ca.Dispose();
        packageManager.Dispose();
 
        if (launchIntent != null)
        {
            launchIntent.Dispose();
        }
    }
cs

 

 

깔깔

'개발 > Unity' 카테고리의 다른 글

[Unity] Inspector의 속성 on/off  (0) 2021.01.11
[Unity] send email android intent  (1) 2020.12.15
[Unity] 3D 오브젝트를 캔버스에 위치시키기  (0) 2020.10.13
[Unity] set screen orientation  (0) 2019.05.24
[Unity] cannot click button  (0) 2019.05.23

+ Recent posts