Пример #1
0
    public void ShareText(string text)
    {
#if UNITY_ANDROID
        AndroidNativeFunctions.ShareText(text, "", "Robo Flight");
#elif UNITY_IOS
        NativeShare.Share(text);
#endif
    }
    void Window1()
    {
        if (GUI.Button(NewRect(5, 5, 40, 10), "Start App", style))
        {
            AndroidNativeFunctions.StartApp("com.google.android.youtube", false);
        }

        if (GUI.Button(NewRect(5, 20, 40, 10), "Get Installed Apps", style))
        {
            List <PackageInfo> packageInfo = AndroidNativeFunctions.GetInstalledApps();
            for (int i = 0; i < packageInfo.Count; i++)
            {
                print("firstInstallTime:" + packageInfo[i].firstInstallTime + " , lastUpdateTime: " + packageInfo[i].lastUpdateTime + " , packageName: " +
                      packageInfo[i].packageName + " , versionCode: " + packageInfo[i].versionCode + " ,  versionName: " + packageInfo[i].versionName);
            }
        }

        if (GUI.Button(NewRect(5, 35, 40, 10), "Get App Info", style))
        {
            PackageInfo packageInfo = AndroidNativeFunctions.GetAppInfo();
            //PackageInfo packageInfo = AndroidNativeFunctions.GetAppInfo("com.google.android.youtube");
            print("firstInstallTime:" + packageInfo.firstInstallTime + " , lastUpdateTime: " + packageInfo.lastUpdateTime + " , packageName: " +
                  packageInfo.packageName + " , versionCode: " + packageInfo.versionCode + " ,  versionName: " + packageInfo.versionName);
        }

        if (GUI.Button(NewRect(5, 50, 40, 10), "Get Device Info", style))
        {
            DeviceInfo deviceInfo = AndroidNativeFunctions.GetDeviceInfo();
            print(" CODENAME: " + deviceInfo.CODENAME + " , INCREMENTAL: " + deviceInfo.INCREMENTAL + " , RELEASE: " + deviceInfo.RELEASE
                  + " , SDK: " + deviceInfo.SDK);
        }

        if (GUI.Button(NewRect(5, 65, 40, 10), "Get Android ID", style))
        {
            print("Android ID: " + AndroidNativeFunctions.GetAndroidID());
        }

        if (GUI.Button(NewRect(55, 5, 40, 10), "Share Text", style))
        {
            AndroidNativeFunctions.ShareText("Hello World", "Subject", "Share Text");
        }

        if (GUI.Button(NewRect(55, 20, 40, 10), "Share Image", style))
        {
            AndroidNativeFunctions.ShareImage("Hello World", "Subject", "Share Text", shareTexture);
        }

        if (GUI.Button(NewRect(55, 35, 40, 10), "Show Progress Dialog", style))
        {
            AndroidNativeFunctions.ShowProgressDialog("Wait 2 seconds please");
            Invoke("HideProgressDialog", 2);
        }

        if (GUI.Button(NewRect(55, 50, 40, 10), "Show Toast", style))
        {
            AndroidNativeFunctions.ShowToast("Hello World", false);
        }

        if (GUI.Button(NewRect(55, 65, 40, 10), "Immersive Mode", style))
        {
            AndroidNativeFunctions.ImmersiveMode();
        }

        if (GUI.Button(NewRect(5, 80, 40, 10), "<<", style))
        {
            window = 3;
        }

        if (GUI.Button(NewRect(55, 80, 40, 10), ">>", style))
        {
            window = 2;
        }
    }