本文整理匯總了Java中com.tencent.tauth.Tencent類的典型用法代碼示例。如果您正苦於以下問題:Java Tencent類的具體用法?Java Tencent怎麽用?Java Tencent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Tencent類屬於com.tencent.tauth包,在下文中一共展示了Tencent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initDatas
import com.tencent.tauth.Tencent; //導入依賴的package包/類
@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);
}
};
}
示例2: click
import com.tencent.tauth.Tencent; //導入依賴的package包/類
public void click(View view) {
switch (view.getId()) {
case R.id.qq:
mTencent = Tencent.createInstance("1106511166", this.getApplicationContext());
if (!mTencent.isSessionValid()) {
mTencent.login(this, "1106511166", listener);
}
break;
case R.id.share:
getUserInfo();
break;
}
}
示例3: onCreateView
import com.tencent.tauth.Tencent; //導入依賴的package包/類
@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;
}
示例4: shareWebPageQQFriend
import com.tencent.tauth.Tencent; //導入依賴的package包/類
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);
}
示例5: shareAppQQ
import com.tencent.tauth.Tencent; //導入依賴的package包/類
public static void shareAppQQ(final Activity activity,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_APP);
params.putString(QQShare.SHARE_TO_QQ_TITLE, "優分享");
params.putString(QQShare.SHARE_TO_QQ_SUMMARY, "優分享是一個內嵌移動瀏覽器的網頁圖片社交分享軟件。\n" +
"優分享可以向你的朋友家人收發文字,語音,動態圖片,視頻等信息。");
params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, "http://youkes.oss.aliyuncs.com/icon/icon_96.png");
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "優分享");
api.shareToQQ(activity, params, listener);
}
示例6: shareToQzone
import com.tencent.tauth.Tencent; //導入依賴的package包/類
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);
}
示例7: initPlatforms
import com.tencent.tauth.Tencent; //導入依賴的package包/類
/**
* 分享界麵初始化各個分享平台的信息
*
* @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);
}
示例8: onActivityResult
import com.tencent.tauth.Tencent; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Constants.REQUEST_LOGIN
|| requestCode == Constants.REQUEST_APPBAR) {
IUiListener listener = LoginByQQ.getmUiListener();
if (listener != null) {
Tencent.onActivityResultData(requestCode, resultCode, data,
listener);
}
}
SsoHandler ssoHandler = LoginByWB.getmSsoHandler();
if (ssoHandler != null) {
ssoHandler.authorizeCallBack(requestCode, resultCode, data);
}
}
示例9: shareToQZone
import com.tencent.tauth.Tencent; //導入依賴的package包/類
/**
* 分享到QQ空間
*/
static void shareToQZone(final Activity activity, final ShareContent shareContent) {
DebugLog.d(TAG, "shareToQZone() shareContent = " + shareContent);
new Thread(new Runnable() {
@Override
public void run() {
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, shareContent.getTitle());
params.putString(QzoneShare.SHARE_TO_QQ_SUMMARY, shareContent.getSummary());
//注意:APP分享不支持傳目標鏈接
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, shareContent.getLinkUrl());
params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, shareContent.getImages());
Tencent tencent = MyApp.getApp().getTencent();
tencent.shareToQzone(activity, params, null);
}
}).start();
}
示例10: onCreate
import com.tencent.tauth.Tencent; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
if(intent == null){
finish();
return;
}
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintResource(R.color.app_main_theme_color);
}
inflater = LayoutInflater.from(this);
mTencent = Tencent.createInstance(Globe.QQ_APP_ID, this);
mAuthInfo = new AuthInfo(this, Globe.SINA_APP_KEY, Globe.SINA_REDIRECT_URL, null);
mSsoHandler = new SsoHandler(this, mAuthInfo);
mIWeiboShareAPI = WeiboShareSDK.createWeiboAPI(this, Globe.SINA_APP_KEY);
mIWeiboShareAPI.registerApp();
}
示例11: initTencent
import com.tencent.tauth.Tencent; //導入依賴的package包/類
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();
}
}
示例12: initTencent
import com.tencent.tauth.Tencent; //導入依賴的package包/類
/**
* 初始化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();
}
}
示例13: getTencent
import com.tencent.tauth.Tencent; //導入依賴的package包/類
public static Tencent getTencent(Context context) {
if (tencent != null && tencent.isSessionValid()) {
} else {
String access_token = PreferenceManager.getString(context,
PreferenceManager.KEY_LOGIN_QQ_ACCESS_TOKEN, "");
String openid = PreferenceManager.getString(context,
PreferenceManager.KEY_LOGIN_QQ_OPEN_ID, "");
String expires_in = PreferenceManager.getString(context,
PreferenceManager.KEY_LOGIN_QQ_EXPIRES_IN, "0");
tencent = Tencent.createInstance(LoginQqActivity.APP_ID, context);
tencent.setAccessToken(access_token, expires_in);
tencent.setOpenId(openid);
}
return tencent;
}
示例14: onActivityResultByShare
import com.tencent.tauth.Tencent; //導入依賴的package包/類
public void onActivityResultByShare(Activity activity,int requestCode, int resultCode, Intent data){
Tencent.onActivityResultData(requestCode, resultCode, data, mShareListener);
if (requestCode == Constants.REQUEST_QQ_SHARE) {
if (resultCode == Constants.ACTIVITY_OK) {
Tencent.handleResultData(data, mShareListener);
}
}else{
String path = null;
if (resultCode == Activity.RESULT_OK && requestCode == 0) {
if (data != null && data.getData() != null) {
// 根據返回的URI獲取對應的SQLite信息
Uri uri = data.getData();
path = QQUtil.getPath(activity, uri);
}
}
Log.d(TAG," user selected path = " + path );
//path may be null;
}
}
示例15: logout
import com.tencent.tauth.Tencent; //導入依賴的package包/類
private void logout() {
switch (context.getSharedPreferences(Constants.SP_USER,0).getString(Constants.LOGIN_WAY, "")) {
case Constants.QQ:
Tencent tencent = Tencent.createInstance("1104326437",context);
tencent.logout(context);
clearLocal();
Toast.makeText(context, "已登出",
Toast.LENGTH_SHORT).show();
callUserInfoListener();
break;
case Constants.SINA:
logOut( SHARE_MEDIA.SINA);
break;
default:
break;
}
}