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"); }
private void TencentTranslation() { chkQQ.Checked = false; chkQQ.Enabled = false; textQQ.Text = Tencent.Translation(textOriginal.Text, langDic["百度"][cobForm.Text], langDic["百度"][cobTo.Text]); chkQQ.Enabled = true; chkQQ.Checked = true; }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { if (requestCode == Constants.RequestLogin) { Tencent.OnActivityResultData(requestCode, (int)resultCode, data, this); } base.OnActivityResult(requestCode, resultCode, data); }
/// <summary> /// https://wiki.connect.qq.com/qq%e7%99%bb%e5%bd%95 /// <para>Tencent类是SDK的主要实现类,开发者可通过Tencent类访问腾讯开放的OpenAPI。</para> /// <para>其中APP_ID是分配给第三方应用的appid,类型为String。</para> /// <para>其中Authorities为 Manifest文件中注册FileProvider时设置的authorities属性值 </para> /// </summary> /// <param name="context"></param> /// <returns></returns> public static Tencent GetTencent(Context context) { var tencent = Tencent.CreateInstance( APP_ID, context.ApplicationContext, GoToPlatformPages.GetAuthority(context)); return(tencent !); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (requestCode == Com.Tencent.Connect.Common.Constants.RequestLogin) { var result = Tencent.OnActivityResultData(requestCode, (int)resultCode, data, loginUIListener); } base.OnActivityResult(requestCode, resultCode, data); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); _tv = FindViewById <TextView>(Resource.Id.textView1); _tencent = Tencent.CreateInstance("1106970090", this.ApplicationContext); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; }
/// <summary> /// API 包装 /// </summary> /// <param name="appId"></param> /// <param name="activity"></param> /// <param name="appName">手Q客户端顶部,替换“返回”按钮文字,如果为空,用返回代替</param> public api(string appId, Activity activity, string appName) { tencent = Tencent.CreateInstance(appId, this.activity = activity); this.appName = appName; }
/// <summary> /// https://wiki.connect.qq.com/server-side%E7%99%BB%E5%BD%95%E6%A8%A1%E5%BC%8F /// </summary> /// <typeparam name="TActivity"></typeparam> /// <param name="tencent"></param> /// <param name="activity"></param> /// <param name="scope"></param> /// <returns></returns> public static int LoginServerSide <TActivity>(this Tencent tencent, TActivity activity, string scope = "get_user_info") where TActivity : Activity, IUiListener => tencent.LoginServerSide(activity, scope, activity);