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); }
#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); }); }