com.tencent.tauth.Tencent Java Examples
The following examples show how to use
com.tencent.tauth.Tencent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QQShareApi.java From browser with GNU General Public License v2.0 | 6 votes |
public static void shareToQzone (final Activity activity,final String url,final String title,final String desc,final String img,IUiListener listener) { if (api == null) { api = Tencent.createInstance(APP_ID, MainApp.getContext()); } if(api==null){ return; } ArrayList<String> imgs=new ArrayList<>(); if(!StringUtils.isEmpty(img)) { imgs.add(img); }else{ imgs.add("http://youkes.oss.aliyuncs.com/icon/icon_96.png"); } final Bundle params = new Bundle(); params.putString(QzoneShare.SHARE_TO_QQ_TITLE, title);//必填 params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, desc);//选填 params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, url);//必填 params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imgs); api.shareToQzone(activity, params, listener); }
Example #2
Source File: MainActivity.java From BookReader with Apache License 2.0 | 6 votes |
@Override public void initDatas() { startService(new Intent(this, DownloadBookService.class)); mTencent = Tencent.createInstance("1105670298", MainActivity.this); mDatas = Arrays.asList(getResources().getStringArray(R.array.home_tabs)); mTabContents = new ArrayList<>(); mTabContents.add(new RecommendFragment()); mTabContents.add(new CommunityFragment()); mTabContents.add(new FindFragment()); mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public int getCount() { return mTabContents.size(); } @Override public Fragment getItem(int position) { return mTabContents.get(position); } }; }
Example #3
Source File: QQShareApi.java From browser with GNU General Public License v2.0 | 6 votes |
public static void shareWebPageQQFriend(final Activity activity,final String url,final String title,final String desc,final String img,IUiListener listener ){ if (api == null) { api = Tencent.createInstance(APP_ID, MainApp.getContext()); } if(api==null){ return; } final Bundle params = new Bundle(); params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT); params.putString(QQShare.SHARE_TO_QQ_TITLE, title); params.putString(QQShare.SHARE_TO_QQ_SUMMARY, desc); params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, url); String postimg=img; if(StringUtils.isEmpty(img)) { postimg="http://youkes.oss.aliyuncs.com/icon/icon_96.png"; } params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL,postimg); params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "优分享"); api.shareToQQ(activity, params,listener); }
Example #4
Source File: BaseDialog.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.base_dialog, container, false); AnimationUtils.slideToUp(view); view.findViewById(R.id.share_sinaweibo_box).setOnClickListener(this); view.findViewById(R.id.share_wechat_friend_box).setOnClickListener(this); view.findViewById(R.id.share_weichat_timeline_box).setOnClickListener(this); view.findViewById(R.id.share_qq_box).setOnClickListener(this); registerToWx(); mTencent = Tencent.createInstance(Constants.TENCENT_APPID, mContext); shareText = mContext.getResources().getString(R.string.shareText); shareLink = wechatShareLink; return view; }
Example #5
Source File: QuShiDetailActivity.java From QiQuYing with Apache License 2.0 | 6 votes |
private void initTencent() { try { ApplicationInfo appInfo = this.getPackageManager() .getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); int appId = appInfo.metaData.getInt("TECENT_APPID", -1); if(appId == -1) { return; } App.mTencent = Tencent.createInstance(String.valueOf(appId), this.getApplicationContext()); String openId = spUtil.getString(com.tencent.connect.common.Constants.PARAM_OPEN_ID, null); String token = spUtil.getString(com.tencent.connect.common.Constants.PARAM_ACCESS_TOKEN, null); long expires = spUtil.getLong(com.tencent.connect.common.Constants.PARAM_EXPIRES_IN, System.currentTimeMillis()); if(openId != null) { App.mTencent.setOpenId(openId); } if(token != null) { App.mTencent.setAccessToken(token, String.valueOf((expires-System.currentTimeMillis())/1000)); } } catch (NameNotFoundException e) { e.printStackTrace(); } }
Example #6
Source File: MainActivity.java From fangzhuishushenqi with Apache License 2.0 | 6 votes |
@Override public void initDatas() { startService(new Intent(this, DownloadBookService.class)); mTencent = Tencent.createInstance("1105670298", MainActivity.this); mDatas = Arrays.asList(getResources().getStringArray(R.array.home_tabs)); mTabContents = new ArrayList<>(); mTabContents.add(new RecommendFragment()); mTabContents.add(new CommunityFragment()); mTabContents.add(new FindFragment()); mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public int getCount() { return mTabContents.size(); } @Override public Fragment getItem(int position) { return mTabContents.get(position); } }; }
Example #7
Source File: CoinDetailsActivity.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); hideProgress(); // Tencent.onActivityResultData(requestCode, resultCode, data, new BaseUIListener(CoinDetailsActivity.this, true)); if (requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE || requestCode == Constants.REQUEST_OLD_SHARE) { Tencent.handleResultData(data, new BaseUIListener(CoinDetailsActivity.this, true)); } if (requestCode == 100 && resultCode == 300) { if (data.getExtras().getString("coin_type").equals(accountWithCoinBean.getCoinName())) { mDataBeanList.clear(); page = 0; mPostChainHistoryBean.setPage(page); presenter.getTransferHistoryData(mPostChainHistoryBean); BigDecimal oldcoinforcny = new BigDecimal(accountWithCoinBean.getCoinForCny()); BigDecimal oldcoin = new BigDecimal(accountWithCoinBean.getCoinNumber()); BigDecimal minuscny = new BigDecimal(data.getExtras().getString("coin_cny")); BigDecimal minuscoin = new BigDecimal(data.getExtras().getString("coin_number")); mIconTotalNumber.setText(StringUtils.addComma(BigDecimalUtil.minus(oldcoinforcny, minuscny, 4) + "") + " CNY"); mIconNumber.setText(StringUtils.addComma(BigDecimalUtil.minus(oldcoin, minuscoin, 4) + "") + " " + accountWithCoinBean.getCoinName()); mIconRmbNumber.setText("≈" + StringUtils.addComma(BigDecimalUtil.minus(oldcoinforcny, minuscny, 4) + "") + " CNY"); } } }
Example #8
Source File: TencentUtils.java From QiQuYing with Apache License 2.0 | 6 votes |
/** * 初始化mTencent * @param context * @param spUtil */ public static void initTencent(Context context, SharePreferenceUtil spUtil) { try { ApplicationInfo appInfo = context.getPackageManager() .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); int appId = appInfo.metaData.getInt("TECENT_APPID", -1); if(appId == -1) { return; } App.mTencent = Tencent.createInstance(String.valueOf(appId), context); String openId = spUtil.getString(com.tencent.connect.common.Constants.PARAM_OPEN_ID, null); String token = spUtil.getString(com.tencent.connect.common.Constants.PARAM_ACCESS_TOKEN, null); long expires = spUtil.getLong(com.tencent.connect.common.Constants.PARAM_EXPIRES_IN, System.currentTimeMillis()); if(openId != null) { App.mTencent.setOpenId(openId); } if(token != null) { App.mTencent.setAccessToken(token, String.valueOf((expires-System.currentTimeMillis())/1000)); } } catch (Exception e) { e.printStackTrace(); } }
Example #9
Source File: LoginActivity.java From Social with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { Tencent.onActivityResultData(requestCode, resultCode, data, loginListener); } if (requestCode==REQUEST_CODE_SET_ACCOUNT && resultCode==RESULT_OK){ //登录 loginWithQQopenid(); } if (requestCode == REQUEST_CODE_REGIST && resultCode ==RESULT_OK){ SocialMainActivity.startSelf(this); finish(); } super.onActivityResult(requestCode, resultCode, data); }
Example #10
Source File: BlackBoxCoinDetailsActivity.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); hideProgress(); if (requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE || requestCode == Constants.REQUEST_OLD_SHARE) { Tencent.handleResultData(data, new BaseUIListener(BlackBoxCoinDetailsActivity.this, true)); } if (requestCode == 100 && resultCode == 300) { if (data.getExtras().getString("coin_type").equals(accountWithCoinBean.getCoinName())) { mDataBeanList.clear(); page = 0; mPostChainHistoryBean.setPage(0); presenter.getTransferHistoryData(mPostChainHistoryBean); } } }
Example #11
Source File: ShareModel.java From Android-Application-ZJB with Apache License 2.0 | 6 votes |
/** * 分享界面初始化各个分享平台的信息 * * @param context WXEntryActivity * @param intent WXEntryActivity.getintent * @param handleResponse 是否要处理回调类型 savedInstanceState != null */ public void initPlatforms(Context context, Intent intent, boolean handleResponse) { mContext = context; //1.得到分享的Activity WXEntryActivity activity = (WXEntryActivity) context; //2.初始化微博平台的信息 //2.1.创建分享API实例 mWeiboShareAPI = WeiboShareSDK.createWeiboAPI(activity, ShareConstant.SINA_APP_KEY); //2.2.注册app,微博的注册需要放到点击的时候进入的哦 //mWeiboShareAPI.registerApp(); //2.3.当 Activity 被重新初始化时(该 Activity 处于后台时,可能会由于内存不足被杀掉了), // 需要调用 {@link IWeiboShareAPI#handleWeiboResponse} 来接收微博客户端返回的数据。 // 执行成功,返回 true,并调用 {@link IWeiboHandler.Response#onResponse}; // 失败返回 false,不调用上述回调 if (handleResponse) { handleWeiboResponse(intent, activity); } //3.初始化QQ分享相关 mTencent = Tencent.createInstance(ShareConstant.QQ_APP_KEY, activity); }
Example #12
Source File: TuDetailActivity.java From QiQuYing with Apache License 2.0 | 5 votes |
private void initTencent() { try { ApplicationInfo appInfo = this.getPackageManager() .getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); int appId = appInfo.metaData.getInt("TECENT_APPID", -1); if (appId == -1) { return; } App.mTencent = Tencent.createInstance(String.valueOf(appId), this.getApplicationContext()); String openId = spUtil.getString( com.tencent.connect.common.Constants.PARAM_OPEN_ID, null); String token = spUtil.getString( com.tencent.connect.common.Constants.PARAM_ACCESS_TOKEN, null); long expires = spUtil.getLong( com.tencent.connect.common.Constants.PARAM_EXPIRES_IN, System.currentTimeMillis()); if (openId != null) { App.mTencent.setOpenId(openId); } if (token != null) { App.mTencent .setAccessToken(token, String.valueOf((expires - System .currentTimeMillis()) / 1000)); } } catch (NameNotFoundException e) { e.printStackTrace(); } }
Example #13
Source File: MainActivity.java From BookReader with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { Tencent.onActivityResultData(requestCode, resultCode, data, loginListener); } super.onActivityResult(requestCode, resultCode, data); }
Example #14
Source File: ShareHandlerActivity.java From ShareSDK with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE) { Tencent.onActivityResultData(requestCode, resultCode, data, null); } }
Example #15
Source File: ProfileCenterMainActivity.java From mobile-manager-tool with MIT License | 5 votes |
private void initUI() { userIcon = (ImageView) this.findViewById(R.id.setting_user_iocn); userName = (TextView) this.findViewById(R.id.setting_user_name); // 创建QQ实例 mQQAuth = QQAuth.createInstance(SDK.QQ_APP_ID, this.getApplicationContext()); mTencent = Tencent.createInstance(SDK.QQ_APP_ID, this); }
Example #16
Source File: LoginActivity.java From MyHearts with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("ruolan", "-->onActivityResult " + requestCode + " resultCode=" + resultCode); if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { Tencent.onActivityResultData(requestCode, resultCode, data, loginListener); } super.onActivityResult(requestCode, resultCode, data); }
Example #17
Source File: QQLoginInstance.java From smart-farmer-android with Apache License 2.0 | 5 votes |
public QQLoginInstance(Activity activity, final LoginListener listener, final boolean fetchUserInfo) { super(activity, listener, fetchUserInfo); mTencent = Tencent.createInstance(ShareManager.CONFIG.getQqId(), activity.getApplicationContext()); mLoginListener = listener; mIUiListener = new IUiListener() { @Override public void onComplete(Object o) { ShareLogger.i(INFO.QQ_AUTH_SUCCESS); try { QQToken token = QQToken.parse((JSONObject) o); if (fetchUserInfo) { listener.beforeFetchUserInfo(token); fetchUserInfo(token); } else { listener.loginSuccess(new LoginResult(LoginPlatform.QQ, token)); } } catch (JSONException e) { ShareLogger.i(INFO.ILLEGAL_TOKEN); mLoginListener.loginFailure(e); } } @Override public void onError(UiError uiError) { ShareLogger.i(INFO.QQ_LOGIN_ERROR); listener.loginFailure( new Exception("QQError: " + uiError.errorCode + uiError.errorDetail)); } @Override public void onCancel() { ShareLogger.i(INFO.AUTH_CANCEL); listener.loginCancel(); } }; }
Example #18
Source File: QQZoneShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data, SocializeListeners.ShareListener listener) { super.onActivityResult(activity, requestCode, resultCode, data, listener); if (requestCode == Constants.REQUEST_QZONE_SHARE) { Log.d(TAG, "handle on activity result"); Tencent.onActivityResultData(requestCode, resultCode, data, mUiListener); } }
Example #19
Source File: QQSSOProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
public static void logout(Context context, String appId) { Tencent tencent = getTencentInstance(context, appId); if (SocialSSOProxy.isTokenValid(context)) { tencent.logout(context); } QQSSOProxy.tencent = null; }
Example #20
Source File: QQChatShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data, SocializeListeners.ShareListener listener) { super.onActivityResult(activity, requestCode, resultCode, data, listener); if (requestCode == Constants.REQUEST_QQ_SHARE) { Log.d(TAG, "handle on activity result"); Tencent.onActivityResultData(requestCode, resultCode, data, mUiListener); } }
Example #21
Source File: LogOnActivity.java From nono-android with GNU General Public License v3.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Log.d(TAG, "-->onActivityResult " + requestCode + " resultCode=" + resultCode); if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { Util.showProgressDialog(LogOnActivity.this,"正在登陆","登陆中..."); Tencent.onActivityResultData(requestCode,resultCode,data,loginListener); } super.onActivityResult(requestCode, resultCode, data); }
Example #22
Source File: LogOnActivity.java From nono-android with GNU General Public License v3.0 | 5 votes |
void registerEvent() { if (mTencent == null) { mTencent = Tencent.createInstance(SharePanelView.QQ_API_ID, this); } mLogOnButton.setOnClickListener(this); mRegisterButton.setOnClickListener(this); tv_find_password.setOnClickListener(this); tv_quick_log_on.setOnClickListener(this); final Animation arrowRight2Down = AnimationUtils.loadAnimation(this,R.anim.rotate_arrow_right_to_down); final Animation arrowDown2Right = AnimationUtils.loadAnimation(this,R.anim.rotate_arrow_down_to_right); mLogOnButton.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mLogOnButton.setAnimation(arrowRight2Down); arrowRight2Down.startNow(); arrowRight2Down.setFillAfter(true); } }); passwordEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if(hasFocus){ arrowRight2Down.cancel(); mLogOnButton.clearAnimation(); mLogOnButton.setAnimation(arrowDown2Right); arrowDown2Right.startNow(); arrowDown2Right.setFillAfter(true); } } }); }
Example #23
Source File: LoginActivity.java From MyHearts with Apache License 2.0 | 5 votes |
@Override public void initView() { //QQ的初始化 mTencent = Tencent.createInstance("1105704769", this.getApplicationContext()); mInfo = new UserInfo(this, mTencent.getQQToken()); mReLogin = (RelativeLayout) findViewById(re_login); mEtPhone = (EditText) findViewById(R.id.et_phone); mEtPassword = (EditText) findViewById(R.id.et_password); mIsPasswordMemory = (CheckBox) findViewById(R.id.is_password_memory); boolean isSelect = PreferencesUtils.getBoolean(LoginActivity.this, "is_select"); mIsPasswordMemory.setChecked(isSelect); mTvForgetPassword = (TextView) findViewById(R.id.tv_forget_password); mRegisterAccount = (TextView) findViewById(R.id.register_account); mApplicationConsultant = (TextView) findViewById(R.id.application_consultant); mQqLogin = (ImageView) findViewById(R.id.qq_login); mSinaLogin = (ImageView) findViewById(R.id.sina_login); mWxLogin = (ImageView) findViewById(R.id.wx_login); String username = PreferencesUtils.getString(this, "user"); String password = PreferencesUtils.getString(this, "pwd"); if (!TextUtils.isEmpty(username)) { mEtPhone.setText(username); } if (!TextUtils.isEmpty(password)) { mEtPassword.setText(password); } }
Example #24
Source File: QQAuthManager.java From sharesdk with Apache License 2.0 | 5 votes |
QQAuthManager(Context context) { mContext = context; mAppId = ShareSDK.getInstance().getQQAppId(); if (!TextUtils.isEmpty(mAppId)) { mTencent = Tencent.createInstance(mAppId, context); } }
Example #25
Source File: TencentSDKHelper.java From Jide-Note with MIT License | 5 votes |
public void implTencent() { if (mTencent == null) { String appId = mContext.getResources().getString(R.string.tencent_app_id); mTencent = Tencent.createInstance(appId, mContext.getApplicationContext()); } }
Example #26
Source File: QQShareProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
public static void shareToQZone(Context context, String appId, String title, String summary, String url, String imageUrl, IUiListener listener) { Bundle params = new Bundle(); params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneShare.SHARE_TO_QZONE_TYPE_IMAGE_TEXT); params.putString(QzoneShare.SHARE_TO_QQ_TITLE, title); params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, summary); params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, url); ArrayList<String> imgs = new ArrayList<String>(); imgs.add(imageUrl); params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imgs); Tencent tencent = getInstance(context, appId); tencent.shareToQzone((Activity) context, params, listener); }
Example #27
Source File: LoginFragment.java From Social with Apache License 2.0 | 5 votes |
@Override public void onAttach(Activity activity) { super.onAttach(activity); loginFragmentCallback = (LoginFragmentCallback)activity; mTencent = Tencent.createInstance("1105431865", MyApplication.mContext); loginListener = new QQIUiListener(){ @Override public void onComplete(Object response) { //super.onComplete(response); Log.d("QQLogin","QQ登录成功"); } }; }
Example #28
Source File: QQHelper.java From SocialHelper with Apache License 2.0 | 5 votes |
QQHelper(Activity activity, String appId) { this.activity = activity; this.appId = appId; if (TextUtils.isEmpty(appId)) { Log.w("QQHelper", "QQ's appId is empty!"); return; } tencent = Tencent.createInstance(appId, activity.getApplicationContext()); }
Example #29
Source File: QQSSOProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
public static Tencent getTencentInstance(Context context, String appId) { if (tencent == null) { tencent = Tencent.createInstance(appId, context); } return tencent; }
Example #30
Source File: LoginFragment.java From Social with Apache License 2.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("QQLogin","回调111111"); if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) { Tencent.onActivityResultData(requestCode,resultCode,data,loginListener); } super.onActivityResult(requestCode, resultCode, data); }