【问题标题】:Opening an android studio application(apk) from a Unity android application with a button使用按钮从 Unity android 应用程序打开 android studio 应用程序(apk)
【发布时间】:2017-01-23 23:14:20
【问题描述】:

我想合并我的应用程序,以便当我浏览统一 android 应用程序用户界面并单击按钮时,我构建的 android studio 应用程序会弹出。我该怎么做?

【问题讨论】:

标签: android unity3d


【解决方案1】:

试试kingandroid at unity forums写的这个

        bool fail = false;
        string bundleId = com.google.appname; // your target 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;
        try
        {
            launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
        }
        catch (System.Exception e)
        {
            fail = true;
        }

        if (fail)
        { //open app in store
            Application.OpenURL("https://google.com");
        }
        else //open the app
            ca.Call("startActivity",launchIntent);

        up.Dispose();
        ca.Dispose();
        packageManager.Dispose();
        launchIntent.Dispose();

此代码用于从 Unity 应用程序中打开 Unity 应用程序。我不是 Android(或 android studio)方面的专家,所以我不确定它是否适用于这些应用。

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 2019-07-29
    • 2013-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    相关资源
    最近更新 更多