Beispiel #1
0
    private void Mail2()
    {
        SA_ScreenUtil.TakeScreenshot((screenshot) => {
            AN_Intent sendIntent = new AN_Intent();
            sendIntent.SetAction(AN_Intent.ACTION_SEND_MULTIPLE);
            sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "This is my text to send.");
            sendIntent.SetType(AN_MIMEDataType.Image);

            sendIntent.PutExtra(AN_Intent.EXTRA_EMAIL, "*****@*****.**", "*****@*****.**");
            sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "EXTRA_TEXT2");
            sendIntent.PutExtra(AN_Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT2s");
            var list = new List <Texture2D>()
            {
                screenshot, screenshot
            };
            sendIntent.PutExtra(AN_Intent.EXTRA_STREAM, list.ToArray());

            AN_Intent chooser      = AN_Intent.CreateChooser(sendIntent, "My chooser title");
            AN_ProxyActivity proxy = new AN_ProxyActivity();
            proxy.StartActivityForResult(chooser, (result) => {
                Debug.Log("Unity: Activity Result: " + result.ResultCode.ToString());
                proxy.Finish();
            });
        });
    }
        protected AN_Intent GenerateChooserIntent(string title, params string[] filters)
        {
            if (filters.Length == 0)
            {
                return(AN_Intent.CreateChooser(ShareIntent, title));
            }

            //Simple intent to get list of the apps that can support the send action
            var testIntent = new AN_Intent();

            testIntent.SetAction(AN_Intent.ACTION_SEND);
            testIntent.SetType("text/plain");


            var pm = AN_MainActivity.Instance.GetPackageManager();
            var resolveInfoList = pm.QueryIntentActivities(testIntent);

            var intentShareList = new List <AN_Intent>();

            foreach (var resInfo in resolveInfoList)
            {
                var packageName = resInfo.ActivityInfo.PackageName;
                foreach (var filterPattern in filters)
                {
                    if (resInfo.ActivityInfo.PackageName.ToLower().Contains(filterPattern) || resInfo.ActivityInfo.Name.ToLower().Contains(filterPattern))
                    {
                        //TODO do we need full data or only package name
                        var intent = new AN_Intent(ShareIntent);
                        intent.SetPackage(packageName);
                        intentShareList.Add(intent);
                        break;
                    }
                }
            }

            if (intentShareList.Count == 0)
            {
                //we can't find packages for a provided filters, so we will use standard chooser
                string filterList = "";
                foreach (var f in filters)
                {
                    filterList += f + ";";
                }
                AN_Logger.Log("Wasn't able to find packages for filters: " + filterList);
                return(AN_Intent.CreateChooser(ShareIntent, title));
            }
            else
            {
                AN_Logger.Log("Chooser created with options count: " + intentShareList.Count);

                //if we have only 1 option there is no point to create hole chooser UI. Let's just use this option
                if (intentShareList.Count == 1)
                {
                    return(intentShareList[0]);
                }

                return(AN_Intent.CreateChooser(ShareIntent, title, intentShareList.ToArray()));
            }
        }
Beispiel #3
0
        public override void Test()
        {
            //Package Info
            string packageName = UnityEngine.Application.identifier;

            var            pm          = AN_MainActivity.Instance.GetPackageManager();
            AN_PackageInfo packageInfo = pm.GetPackageInfo(packageName, 0);

            AN_Logger.Log("packageInfo.VersionName: " + packageInfo.VersionName);
            AN_Logger.Log("packageInfo.PackageName: " + packageInfo.PackageName);
            AN_Logger.Log("packageInfo.SharedUserId: " + packageInfo.SharedUserId);



            //Query Intent Activities TEST

            //Simple intent to get list of the apps that can support the send action
            AN_Intent testIntent = new AN_Intent();

            testIntent.SetAction(AN_Intent.ACTION_SEND);
            testIntent.SetType("text/plain");

            List <AN_ResolveInfo> resolveInfoList = pm.QueryIntentActivities(testIntent, 0);

            foreach (var resolveInfo in resolveInfoList)
            {
                AN_Logger.Log("resolveInfo.ActivityInfo.Name: " + resolveInfo.ActivityInfo.Name);
                AN_Logger.Log("resolveInfo.ActivityInfo.PackageName: " + resolveInfo.ActivityInfo.PackageName);
            }


            ///Open External App
            AN_Intent startAppIntent = pm.GetLaunchIntentForPackage("com.facebook.katana");

            if (startAppIntent == null)
            {
                SetResult(SA_TestResult.WithError("App with Id: com.facebook.katana not found on device"));
                return;
            }
            startAppIntent.AddCategory(AN_Intent.CATEGORY_LAUNCHER);

            /*
             * AN_ProxyActivity proxy = new AN_ProxyActivity();
             * bool started = proxy.StartActivityForResult(startAppIntent, (result) => {
             *  SetResult(TestResult.OK);
             *  proxy.Finish();
             * });
             *
             * if(!started) {
             *  SetResult(TestResult.GetError("Failed to create activity"));
             * }*/

            SetResult(SA_TestResult.OK);
        }
Beispiel #4
0
        /// <summary>
        /// Launch an activity for which you would like a result when it finished.
        /// When this activity exits, your callback will be called.
        /// </summary>
        /// <param name="intent">The intent to start.</param>
        /// <param name="callback">Activity result callback</param>
        public bool StartActivityForResult(AN_Intent intent, Action <AN_ActivityResult> callback)
        {
            if (Application.isEditor)
            {
                SA_Coroutine.WaitForSeconds(1, () => {
                    callback.Invoke(new AN_ActivityResult());
                });
                return(true);
            }

            return(AN_Java.Bridge.CallStaticWithCallback <bool, AN_ActivityResult>(ANDROID_CLASS, "StartActivityForResult", callback, this, intent));
        }
        /// <summary>
        /// Retrieve all activities that can be performed for the given intent.
        /// </summary>
        /// <param name="intent">The desired intent as per resolveActivity().</param>
        /// <param name="flags">
        /// Additional option flags to modify the data returned.
        /// The most important is MATCH_DEFAULT_ONLY, to limit the resolution to only those activities that support the AN_Intent.CATEGORY_DEFAULT.
        /// Or, set MATCH_ALL to prevent any filtering of the results.
        /// Value is either 0 or combination of GET_META_DATA, GET_SIGNATURES, GET_SHARED_LIBRARY_FILES, MATCH_ALL,
        /// MATCH_DISABLED_COMPONENTS, MATCH_DISABLED_UNTIL_USED_COMPONENTS,
        /// MATCH_DEFAULT_ONLY, MATCH_DIRECT_BOOT_AWARE, MATCH_DIRECT_BOOT_UNAWARE,
        /// MATCH_SYSTEM_ONLY or MATCH_UNINSTALLED_PACKAGES.
        /// </param>
        /// <returns></returns>
        public List <AN_ResolveInfo> QueryIntentActivities(AN_Intent intent, int flags = 0)
        {
            if (Application.isEditor)
            {
                return(new List <AN_ResolveInfo>());
            }

            var json   = AN_Java.Bridge.CallStatic <string>(ANDROID_CLASS, "QueryIntentActivities", m_context, intent, flags);
            var result = JsonUtility.FromJson <AN_PackageManagerResolveInfoResult>(json);

            return(result.m_list);
        }
Beispiel #6
0
        public override void Test()
        {
            var intent = new AN_Intent(Provider.AN_Settings.ACTION_SETTINGS);

            AN_MainActivity.Instance.StartActivity(intent);
            SetResult(SA_TestResult.OK);

            /*
             * var m_proxyActivity = new AN_ProxyActivity();
             * m_proxyActivity.StartActivityForResult(intent, (result) => {
             *  m_proxyActivity.Finish();
             *
             *
             * });*/
        }
Beispiel #7
0
    public void ShareWithMe()
    {
        #if UNITY_ANDROID
        AN_Intent sendIntent = new AN_Intent();
        sendIntent.SetAction(AN_Intent.ACTION_SEND);
        sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "Welcome to Lime Crime https://www.limecrime.com");
        sendIntent.SetType("text/plain");
        AN_MainActivity.Instance.StartActivity(AN_Intent.CreateChooser(sendIntent, "Hello Lime Crime!"));
        #endif

        #if UNITY_IOS
        ISN_UIActivityViewController controller = new ISN_UIActivityViewController();
        controller.SetText("Welcome to Lime Crime https://www.limecrime.com");
        controller.Present((result) => { });
        #endif
    }
Beispiel #8
0
        /// <summary>
        /// Use the <see cref="RequestReview"/>  method to indicate when it makes sense
        /// within the logic of your app to ask the user for ratings and reviews within your app.
        /// </summary>
        public static void RequestReview()
        {
            string appName       = Application.productName;
            string appIdentifier = Application.identifier;

            string title     = string.Format("Rate {0}!", appName);
            string message   = string.Format("If you enjoy using {0}, please take a moment to rate it.Thanks for your support!", appName);
            string noTitle   = "No, thanks";
            string rateTitle = "Rate";

            if (Application.isEditor)
            {
                var builder = new UM_NativeDialogBuilder(title, message);
                builder.SetPositiveButton(rateTitle, () => {});
                builder.SetNegativeButton(noTitle, () => {});

                var dialog = builder.Build();
                dialog.Show();
            }

            switch (Application.platform)
            {
            case RuntimePlatform.IPhonePlayer:
                ISN_SKStoreReviewController.RequestReview();
                break;

            case RuntimePlatform.Android:


                var dialog = new AN_AlertDialog(AN_DialogTheme.Default);
                dialog.Title   = title;
                dialog.Message = message;

                dialog.SetNegativeButton(noTitle, () => {
                });

                dialog.SetPositiveButton(rateTitle, () => {
                    //This code will take user to your app Play Market page
                    System.Uri uri       = new System.Uri("market://details?id=" + appIdentifier);
                    AN_Intent viewIntent = new AN_Intent(AN_Intent.ACTION_VIEW, uri);
                    AN_MainActivity.Instance.StartActivity(viewIntent);
                });

                dialog.Show();
                break;
            }
        }
Beispiel #9
0
    private void Mail()
    {
        AN_Intent sendIntent = new AN_Intent();

        sendIntent.SetAction(AN_Intent.ACTION_SEND);
        sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "This is my text to send.");
        sendIntent.SetType("text/plain");
        sendIntent.SetAction(AN_MIMEDataType.Image);

        sendIntent.PutExtra(AN_Intent.EXTRA_EMAIL, "*****@*****.**", "*****@*****.**");
        sendIntent.PutExtra(AN_Intent.EXTRA_TEXT, "EXTRA_TEXT2");
        sendIntent.PutExtra(AN_Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT2s");


        AN_Intent        chooser = AN_Intent.CreateChooser(sendIntent, "My chooser title");
        AN_ProxyActivity proxy   = new AN_ProxyActivity();

        proxy.StartActivityForResult(chooser, (result) => {
            Debug.Log("Unity: Activity Result: " + result.ResultCode.ToString());
            proxy.Finish();
        });
    }
Beispiel #10
0
        //--------------------------------------
        // Public Methods
        //--------------------------------------


        /// <summary>
        /// Launch a new activity.
        /// You will not receive any information about when the activity exits.
        /// This implementation overrides the base version, providing information about the activity performing the launch.
        /// Because of this additional information, the Intent.FLAG_ACTIVITY_NEW_TASK launch flag is not required;
        /// if not specified, the new activity will be added to the task of the caller.
        /// </summary>
        /// <param name="intent">The intent to start.</param>
        public bool StartActivity(AN_Intent intent)
        {
            return(AN_Java.Bridge.CallStatic <bool>(ANDROID_CLASS, "StartActivity", this, intent));
        }
Beispiel #11
0
    void OnPress(bool isDown)
    {
        if (isDown == false)
        {
            AN_FirebaseAnalytics.LogEvent(gameObject.name);

            if (gameObject.name == "More")
            {
                Main.showMoreApps();
            }

            if (gameObject.name == "X" && (stars >= iPage.unlock[PlayerPrefs.GetInt("page")]))
            {
                if (PlayerPrefs.GetInt("page") < 1)
                {
                    iMap.MSG_1.SetActive(true);
                }
                else if (PlayerPrefs.GetInt("page") < 7)
                {
                    iMap.MSG_2.SetActive(true);
                }
                else
                {
                    iMap.MSG_3.SetActive(true);
                }
            }


            if (gameObject.name == "CloseBonus")
            {
                GameObject.Find("BonusInfo").SetActive(false);
            }

            if (gameObject.name == "WFW")
            {
                BonusInfo.SetActive(true);
            }


            if (gameObject.name == "GoolgePLay")
            {
#if UNITY_IOS
                Application.OpenURL("itms-apps://itunes.apple.com/app/id1496515813");
#endif


#if UNITY_ANDROID
                System.Uri uri        = new System.Uri("market://details?id=com.sayrex.wfw2");
                AN_Intent  viewIntent = new AN_Intent(AN_Intent.ACTION_VIEW, uri);
                AN_MainActivity.Instance.StartActivity(viewIntent);
#endif
            }



            if (gameObject.name == "Sharing")
            {
                SX.SendMessage("Sharing");
            }

            if (gameObject.name == "CloseMSG")
            {
                iMap.MSG_1.SetActive(false);
                iMap.MSG_2.SetActive(false);
                iMap.MSG_3.SetActive(false);
            }

            if (gameObject.name == "Map")
            {
                LoadScene(1);
            }
            if (gameObject.name == "Start")
            {
                PlayerPrefs.SetInt("page", 0);
                LoadScene(1);
            }

            if (gameObject.name == "Level" || gameObject.name == "Next")
            {
                LoadScene(2);
            }

            if (gameObject.name == "Panel_buy")
            {
                panel_buy_up();
            }

            if (gameObject.name == "Panel_buys")
            {
                panel_buy_ups();
            }

            if (gameObject.name == "Back")
            {
                LoadScene(0);
            }

            if (gameObject.name == "o_letters")
            {
                Main.Open_Letters();
            }

            if (gameObject.name == "o_words")
            {
                Main.Open_Word();
            }

            if (gameObject.name == "o_wordss")
            {
                Main.Open_Words();
            }

            if (gameObject.name == "AdsRevard")
            {
                GameObject.Find("SX").SendMessage("rewardedAdsShow");
            }

            if (gameObject.name == "Backspace" && Main.next > 0)
            {
                GameObject w = GameObject.Find("letter" + (Main.next - 1).ToString());;
                w.SendMessage("addLetters");
                //Main.check_next();
            }

            if (gameObject.name == "Page_right")
            {
                int page = 0;
                if (PlayerPrefs.HasKey("page"))
                {
                    page = PlayerPrefs.GetInt("page");
                }
                page--;
                if (page < 0)
                {
                    page = 0;
                }
                PlayerPrefs.SetInt("page", page);
                LoadScene(1);
            }

            if (gameObject.name == "pack1")
            {
                Main.onBuy("wfw2_p1");
            }
            if (gameObject.name == "pack2")
            {
                Main.onBuy("wfw2_p2");
            }
            if (gameObject.name == "pack3")
            {
                Main.onBuy("wfw2_p3");
            }
            if (gameObject.name == "pack4")
            {
                Main.onBuy("wfw2_p4");
            }
            if (gameObject.name == "pack5")
            {
                Main.onBuy("wfw2_p5");
            }
            if (gameObject.name == "buy_page")
            {
                Main.onBuy("page_" + PlayerPrefs.GetInt("page").ToString());
            }


            if (gameObject.name == "Page_left")
            {
                int page = 0;
                if (PlayerPrefs.HasKey("page"))
                {
                    page = PlayerPrefs.GetInt("page");
                }
                page++;
                if (page > 7)
                {
                    page = 7;
                }
                PlayerPrefs.SetInt("page", page);
                LoadScene(1);
            }

            if (gameObject.name == "FaceBook")
            {
                Application.OpenURL("https://www.facebook.com/SayrexGames/");
            }

            if (gameObject.name == "Sayrex")
            {
                Application.OpenURL("https://www.facebook.com/SayrexGames/");
            }


            if (gameObject.name == "GameCenter")
            {
                Main.onLeaderBoard();
            }

            if (gameObject.name == "ARCH")
            {
                Main.SX.GetComponent <SX_GameCenter>().showArchievements();
            }


            if (gameObject.name == "sound")
            {
                Debug.Log("Here");
                if (sound)
                {
                    PlayerPrefs.SetInt("sound", 1);
                    sound = false;
                    gameObject.GetComponentInChildren <UISprite>().spriteName = "btn_sound_off";
                    AudioListener.volume = 0;
                }
                else
                {
                    PlayerPrefs.SetInt("sound", 0);
                    sound = true;
                    gameObject.GetComponentInChildren <UISprite>().spriteName = "btn_sound_on";
                    AudioListener.volume = 1;
                }
            }
        }
    }
Beispiel #12
0
        protected override AN_Intent MakeSharingIntent()
        {
            AN_Intent chooser = GenerateChooserIntent(string.Empty, "mail");

            return(chooser);
        }
    void Start()
    {
        m_progressButton.onClick.AddListener(() => {
            //Show the preloader
            AN_Preloader.LockScreen("Please Wait...");

            //and hide it in 2 sec
            SA_Coroutine.WaitForSeconds(2f, () => {
                AN_Preloader.UnlockScreen();
            });
        });

        m_messageButton.onClick.AddListener(() => {
            var message     = new AN_AlertDialog(AN_DialogTheme.Material);
            message.Title   = "Message";
            message.Message = "Some message text";

            message.SetPositiveButton("Okay", () => {
                AN_Logger.Log("message: ok button was clicked");
            });


            message.Show();
        });


        m_dialogButton.onClick.AddListener(() => {
            var dialog     = new AN_AlertDialog(AN_DialogTheme.Light);
            dialog.Title   = "Dialog";
            dialog.Message = "Some dialog text";

            dialog.SetPositiveButton("Yes", () => {
                AN_Logger.Log("dialog: Yes button was clicked");
            });

            dialog.SetNegativeButton("No", () => {
                AN_Logger.Log("dialog: No button was clicked");
            });

            dialog.Show();
        });


        m_rateButton.onClick.AddListener(() => {
            string appName       = Application.productName;
            string appIdentifier = Application.identifier;

            var dialog     = new AN_AlertDialog(AN_DialogTheme.Default);
            dialog.Title   = string.Format("Rate {0}!", appName);
            dialog.Message = string.Format("If you enjoy using {0}, please take a moment to rate it.Thanks for your support!", appName);

            dialog.SetPositiveButton("Rate", () => {
                AN_Logger.Log("dialog: Rate button was clicked");

                //This code will take user to your app Play Market page
                System.Uri uri       = new System.Uri("market://details?id=" + appIdentifier);
                AN_Intent viewIntent = new AN_Intent(AN_Intent.ACTION_VIEW, uri);
                AN_MainActivity.Instance.StartActivity(viewIntent);
            });

            dialog.SetNegativeButton("No, thanks", () => {
                AN_Logger.Log("dialog: No, thanks button was clicked");
            });


            dialog.SetNeutralButton("Remind me later", () => {
                AN_Logger.Log("dialog: Remind me later button was clicked");
            });

            dialog.Show();
        });


        m_calendarButton.onClick.AddListener(() => {
            var date  = DateTime.Now;
            int year  = date.Year;
            int month = date.Month - 1; //Compatibility with Android Calendar..
            int day   = date.Day;

            AN_DatePickerDialog picker = new AN_DatePickerDialog(year, month, day);
            picker.Show((result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log("date picked result.Year: " + result.Year);
                    //Same  Android Calendar Compatibility
                    Debug.Log("date picked result.Month: " + result.Month + 1);
                    Debug.Log("date picked result.Day: " + result.Day);
                }
                else
                {
                    Debug.Log("Failed to pick a date: " + result.Error.FullMessage);
                }
            });
        });
    }
        protected override AN_Intent MakeSharingIntent()
        {
            AN_Intent chooser = GenerateChooserIntent(m_title, m_filters.ToArray());

            return(chooser);
        }
Beispiel #15
0
#pragma warning restore 649

    private void Awake()
    {
        m_shareText.onClick.AddListener(() => {
            var composer = new AN_ShareComposer();
            composer.SetTitle("Android Native Share Example");
            composer.SetText("Hello world");

            composer.Share();
        });

        m_shareImage.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                /*
                 * var composer = new AN_ShareComposer();
                 * composer.SetTitle("Android Native Share Example");
                 * composer.SetText("Hello world");
                 * composer.AddImage(screenshot);
                 *
                 * composer.Share();*/

                ShowSharingMenuAndroid(screenshot);
            });
        });


        m_shareImages.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_ShareComposer();
                composer.SetTitle("Android Native Share Example");
                composer.SetText("Hello world");
                composer.AddImage(screenshot);
                composer.AddImage(screenshot);

                composer.Share(() => {
                    Debug.Log("Sharing flow is finished, User has retured to the app");
                });
            });
        });

        m_fbImage.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_FacebookSharing();
                composer.AddImage(screenshot);

                composer.Share();
            });
        });


        m_fbImages.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_FacebookSharing();
                composer.AddImage(screenshot);
                composer.AddImage(screenshot);

                composer.Share(() => {
                    Debug.Log("Sharing flow is finished, User has retured to the app");
                });
            });
        });


        m_instaImage.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_InstagramSharing();
                composer.AddImage(screenshot);

                composer.Share();
            });
        });


        m_instaImages.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_InstagramSharing();
                composer.AddImage(screenshot);
                composer.AddImage(screenshot);

                composer.Share();
            });
        });

        m_emil.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_EmailComposer();

                composer.SetText("Testing the emailssharing\n example");
                composer.SetSubject("Hello worls");

                composer.AddRecipient("*****@*****.**");
                composer.AddRecipient("*****@*****.**");

                composer.AddImage(screenshot);
                // composer.AddImage(screenshot);

                composer.Share(() => {
                    Debug.Log("Sharing flow is finished, User has retured to the app");
                });
            });
        });



        m_twitter.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_TwitterSharing();
                composer.AddImage(screenshot);
                composer.SetText("My twitt");

                composer.Share();
            });
        });


        m_whatsup.onClick.AddListener(() => {
            SA_ScreenUtil.TakeScreenshot((screenshot) => {
                var composer = new AN_WhatsappSharing();
                composer.AddImage(screenshot);
                composer.AddImage(screenshot);
                composer.SetText("My message");

                composer.Share();
            });
        });


        m_instllCheck.onClick.AddListener(() => {
            AN_Logger.Log(AN_FacebookSharing.IsAppInstalled);


            var pm   = AN_MainActivity.Instance.GetPackageManager();
            var info = pm.GetPackageInfo("random.app.name", AN_PackageManager.GET_ACTIVITIES);

            if (info == null)
            {
                AN_Logger.Log("not installed");
            }
            else
            {
                AN_Logger.Log("app installed");
            }
        });


        m_startFacebook.onClick.AddListener(() => {
            var pm = AN_MainActivity.Instance.GetPackageManager();
            AN_Intent startAppIntent = pm.GetLaunchIntentForPackage("com.facebook.katana");
            if (startAppIntent == null)
            {
                AN_Logger.Log("App with Id: com.facebook.katana not found on device");
                return;
            }
            startAppIntent.AddCategory(AN_Intent.CATEGORY_LAUNCHER);

            AN_MainActivity.Instance.StartActivity(startAppIntent);
        });


        m_composeSMS.onClick.AddListener(() => {
            string phoneNumber  = "+380956808684";
            AN_Intent smsIntent = new AN_Intent(AN_Intent.ACTION_VIEW, new Uri("sms:" + phoneNumber));
            smsIntent.PutExtra("sms_body", "Hello, how are you?");
            smsIntent.PutExtra(AN_Intent.EXTRA_TEXT, "Hello, how are you ?");
            AN_MainActivity.Instance.StartActivity(smsIntent);
        });
    }
Beispiel #16
0
    void ShowSharingMenuAndroid(Texture2D imageToShare)
    {
        var Title   = "Test Title";
        var AppLink = "Test AppLink";

        var PrioritizedApps = new List <string> {
            "whatsapp", "facebook"
        };

        AN_Intent shareIntent = new AN_Intent();

        shareIntent.SetAction(AN_Intent.ACTION_SEND);

        shareIntent.AddFlags(AN_Intent.FLAG_GRANT_READ_URI_PERMISSION);
        shareIntent.SetType(AN_MIMEDataType.Image);

        string sharingMessageText = "Sharing message text.";

        sharingMessageText = sharingMessageText + "\n\n" + AppLink;

        shareIntent.PutExtra(AN_Intent.EXTRA_TEXT, sharingMessageText);
        shareIntent.PutExtra(AN_Intent.EXTRA_STREAM, imageToShare);

        var pm = AN_MainActivity.Instance.GetPackageManager();
        List <AN_ResolveInfo> resolveInfoList = pm.QueryIntentActivities(shareIntent, 0);

        if (resolveInfoList.Count == 0)
        {
            AN_Logger.Log("Could not find any app for sharing.");

            return;
        }

        List <AN_Intent> intentShareList = new List <AN_Intent>();

        // Try to find apps from priority list to put them on the first positions
        foreach (string appName in PrioritizedApps)
        {
            foreach (AN_ResolveInfo resInfo in resolveInfoList)
            {
                string packageName = resInfo.ActivityInfo.PackageName;
                string name        = resInfo.ActivityInfo.Name;

                if (resInfo.ActivityInfo.PackageName.ToLower().Contains(appName) ||
                    resInfo.ActivityInfo.Name.ToLower().Contains(appName))
                {
                    AN_Intent intent = new AN_Intent(shareIntent);
                    intent.SetPackage(packageName);
                    intentShareList.Add(intent);

                    resolveInfoList.Remove(resInfo);

                    break;
                }
            }
        }

        // Put all the others apps after prioritized ones
        for (int resInfoIndex = 0; resInfoIndex < resolveInfoList.Count; resInfoIndex++)
        {
            AN_ResolveInfo resInfo = resolveInfoList[resInfoIndex];

            string packageName = resInfo.ActivityInfo.PackageName;
            string name        = resInfo.ActivityInfo.Name;

            if (resInfoIndex != resolveInfoList.Count - 1)
            {
                AN_Intent intent = new AN_Intent(shareIntent);
                intent.SetPackage(packageName);
                intentShareList.Add(intent);
            }
            else
            {
                shareIntent.SetPackage(packageName);
            }
        }

        if (intentShareList.Count == 0)
        {
            AN_Logger.Log("Could not find any app for sharing.");
        }
        else
        {
            AN_Logger.Log("proxy.StartActivityForResult");

            AN_Intent chooserIntent = AN_Intent.CreateChooser(shareIntent, Title, intentShareList.ToArray());

            /* AN_ProxyActivity proxy = new AN_ProxyActivity();
             * proxy.StartActivityForResult(chooserIntent, (result) => {
             *   Debug.Log("Unity: Activity Result: " + result.ResultCode.ToString());
             *   proxy.Finish();
             * });*/
            AN_MainActivity.Instance.StartActivity(chooserIntent);
        }
    }
Beispiel #17
0
    public static void StartFilteredChooserActivity(Texture2D screenshot)
    {
        AN_Intent shareIntent = new AN_Intent();

        shareIntent.SetAction(AN_Intent.ACTION_SEND_MULTIPLE);
        shareIntent.SetType(AN_MIMEDataType.Image);

        shareIntent.PutExtra(AN_Intent.EXTRA_TEXT, "This is my text to send.");

        shareIntent.PutExtra(AN_Intent.EXTRA_EMAIL, "*****@*****.**", "*****@*****.**");
        shareIntent.PutExtra(AN_Intent.EXTRA_TEXT, "EXTRA_TEXT2");
        shareIntent.PutExtra(AN_Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT2s");
        var list = new List <Texture2D>()
        {
            screenshot, screenshot
        };

        shareIntent.PutExtra(AN_Intent.EXTRA_STREAM, list.ToArray());

        List <string> filters = new List <string>();

        filters.Add("mail");


        var pm = AN_MainActivity.Instance.GetPackageManager();

        List <AN_ResolveInfo> resolveInfoList = pm.QueryIntentActivities(shareIntent, 0);

        if (resolveInfoList.Count == 0)
        {
            Debug.Log("No apps found");
            return;
        }


        List <AN_Intent> intentShareList = new List <AN_Intent>();


        foreach (AN_ResolveInfo resInfo in resolveInfoList)
        {
            string packageName = resInfo.ActivityInfo.PackageName;
            string name        = resInfo.ActivityInfo.Name;

            foreach (string filterPattern in filters)
            {
                AN_Logger.Log(resInfo.ActivityInfo.PackageName);

                if (resInfo.ActivityInfo.PackageName.ToLower().Contains(filterPattern) || resInfo.ActivityInfo.Name.ToLower().Contains(filterPattern))
                {
                    AN_Intent intent = new AN_Intent(shareIntent);
                    intent.SetPackage(packageName);
                    // intent.setComponent(new ComponentName(packageName, name));
                    intentShareList.Add(intent);
                    AN_Logger.Log("packageName: " + packageName);

                    shareIntent.SetPackage(packageName);
                }
            }
        }


        if (intentShareList.Count == 0)
        {
            AN_Logger.Log("CAN'T FIND PACKAGES FOR FILTER: " + filters);
        }
        else
        {
            AN_Logger.Log("SHARE WITH FILTER: " + filters);
            AN_Intent chooserIntent = AN_Intent.CreateChooser(shareIntent, "Hello title", intentShareList.ToArray());
            AN_MainActivity.Instance.StartActivity(chooserIntent);
        }
    }