示例#1
0
        public void sendIntent(string zpTransToken)
        {
            Console.WriteLine(">>> CallNativeSdkDroid:sendIntent ---> " + zpTransToken);
            Console.WriteLine(">>>> " + MainActivity.getCurrentActivity().ToString());


            AndroidAppLinks.Init(MainActivity.getCurrentActivity());
            try
            {
                //Intent intent = new Intent(Intent.ActionSend);
                //intent.AddFlags(ActivityFlags.NewTask);
                ////intent.AddFlags(ActivityFlags.SingleTop);
                //intent.PutExtra("zptranstoken", zpTransToken);
                ////StartActivityForResult(intent, 0);
                //Forms.Context.StartActivity(intent);
                //var pm = Android.App.Application.Context.PackageManager;
                //var uri = Android.Net.Uri.Parse("vn.com.vng.zalopay.sbmc");
                //var intent = new Intent(Intent.ActionView, uri);
                //Xamarin.Forms.Forms.Context.StartActivity(intent);
                //MainActivity.getCurrentContext().StartActivity(intent);

                PayOrderListener payOrderListener = new PayOrderListener();
                ZaloPaySDK.Instance.PayOrder(MainActivity.getCurrentActivity(), zpTransToken ?? string.Empty, "demozpdk://xamarinapp", payOrderListener);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception >>> " + e.ToString());
            }
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // -------------------------------------------------------------------------------------------------------------------------------------
            // Config appid and env
            ZaloPaySDK.Init(120987, VN.Zalopay.Sdk.Environment.Sandbox);
            // -------------------------------------------------------------------------------------------------------------------------------------
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);
            Xamarin.Forms.Forms.SetFlags("SwipeView_Experimental");
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());

            // -------------------------------------------------------------------------------------------------------------------------------------
            MessagingCenter.Subscribe <Xamarin.Forms.Application, string>(Xamarin.Forms.Application.Current, "PayOrder", (sender, zpTransToken) =>
            {
                PayOrderListener payOrderListener = new PayOrderListener();
                // Define URI schema in AndroidManifest.xml
                ZaloPaySDK.Instance.PayOrder(this, zpTransToken ?? string.Empty, "demozpdk://xamarinapp", payOrderListener);

                //Intent intent = new Intent(this.ApplicationContext, typeof(PayOrderListener));
                //intent.AddFlags(ActivityFlags.NewTask);
                ////intent.AddFlags(ActivityFlags.SingleTop);
                //intent.PutExtra("zptranstoken", zpTransToken);
                ////StartActivityForResult(intent, 0);
                //StartActivity(intent);
            });
            // -------------------------------------------------------------------------------------------------------------------------------------
        }