Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
            MessagingCenter.Subscribe <object>(this, MainPage.QQShare, o =>
            {
                var para = new Bundle();
                para.PutInt(QQShare.ShareToQqKeyType, QQShare.ShareToQqTypeDefault);
                para.PutString(QQShare.ShareToQqTitle, "这是来自Xamarin的QQ分享");
                para.PutString(QQShare.ShareToQqTargetUrl, "https://mp.weixin.qq.com/s?__biz=MzUyMjMyNDkyNA==&mid=2247483866&idx=1&sn=51892c4dbca89f3a370a3404184c003a&chksm=f9ccdf09cebb561f6fcc6fa22a5e0c347966cb4dc9c35468ac492d45832327f6f709deb40f18&token=532895856&lang=zh_CN#rd");
                tencent.ShareToQQ(this, para, new UiListener());
            });
            MessagingCenter.Subscribe <object>(this, MainPage.QQLogin, o =>
            {
                loginUIListener = new UiListener();
                var result      = tencent.Login(this, "all", loginUIListener);
            });
            tencent = Tencent.CreateInstance("1110576152", ApplicationContext, "com.tencent.sample.fileprovider");
        }
Example #2
0
        /// <summary>
        /// 分享图片
        /// </summary>
        /// <param name="imageUrl">图片 URI</param>
        /// <param name="isQZone">自动打开分享到QZone的对话框</param>
        /// <param name="callback">回调处理</param>
        public void ShareImage(string imageUrl, bool isQZone = false, IUiListener callback = null)
        {
            Bundle parameters = new Bundle();

            parameters.PutInt(SHARE_TO_QQ_KEY_TYPE, SHARE_TO_QQ_TYPE_IMAGE);
            parameters.PutString(SHARE_TO_QQ_IMAGE_LOCAL_URL, imageUrl);
            if (appName != null)
            {
                parameters.PutString(SHARE_TO_QQ_APP_NAME, appName);
            }
            if (!isQZone)
            {
                parameters.PutInt(SHARE_TO_QQ_EXT_INT, SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE);
            }
            tencent.ShareToQQ(activity, parameters, callback ?? nullUiListener.Null);
        }
Example #3
0
        /// <summary>
        /// 分享网页到 Qzone
        /// </summary>
        /// <param name="url">网页 URI</param>
        /// <param name="title">最多200个字符</param>
        /// <param name="summary">最多600字符</param>
        /// <param name="imageUrls">最多支持9张图片(QZone接口暂不支持发送多张图片的能力,若传入多张图片,则会自动选入第一张图片作为预览图。多图的能力将会在以后支持)</param>
        /// <param name="callback">回调处理</param>
        public void ShareToQzone(string url, string title, string summary = null, IList <string> imageUrls = null, IUiListener callback = null)
        {
            Bundle parameters = new Bundle();

            parameters.PutInt(SHARE_TO_QZONE_KEY_TYPE, SHARE_TO_QZONE_TYPE_IMAGE_TEXT);
            parameters.PutString(SHARE_TO_QQ_TARGET_URL, url);
            parameters.PutString(SHARE_TO_QQ_TITLE, title);
            if (summary != null)
            {
                parameters.PutString(SHARE_TO_QQ_SUMMARY, summary);
            }
            if (imageUrls != null)
            {
                parameters.PutStringArrayList(SHARE_TO_QQ_IMAGE_URL, imageUrls);
            }
            if (appName != null)
            {
                parameters.PutString(SHARE_TO_QQ_APP_NAME, appName);
            }
            tencent.ShareToQzone(activity, parameters, callback ?? nullUiListener.Null);
        }
Example #4
0
        /// <summary>
        /// 分享 APP
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="summary">最长40个字</param>
        /// <param name="imageUrl">图片 URI</param>
        /// <param name="isQZone">自动打开分享到QZone的对话框</param>
        /// <param name="callback">回调处理</param>
        public void ShareApp(string title, string summary = null, string imageUrl = null, bool isQZone = false, IUiListener callback = null)
        {
            Bundle parameters = new Bundle();

            parameters.PutInt(SHARE_TO_QQ_KEY_TYPE, SHARE_TO_QQ_TYPE_APP);
            parameters.PutString(SHARE_TO_QQ_TITLE, title);
            if (summary != null)
            {
                parameters.PutString(SHARE_TO_QQ_SUMMARY, summary);
            }
            if (imageUrl != null)
            {
                parameters.PutString(SHARE_TO_QQ_IMAGE_URL, imageUrl);
            }
            if (appName != null)
            {
                parameters.PutString(SHARE_TO_QQ_APP_NAME, appName);
            }
            if (!isQZone)
            {
                parameters.PutInt(SHARE_TO_QQ_EXT_INT, SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE);
            }
            tencent.ShareToQQ(activity, parameters, callback ?? nullUiListener.Null);
        }