本文整理匯總了Java中com.tencent.tauth.Tencent.createInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java Tencent.createInstance方法的具體用法?Java Tencent.createInstance怎麽用?Java Tencent.createInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.tencent.tauth.Tencent
的用法示例。
在下文中一共展示了Tencent.createInstance方法的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: 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);
}
示例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: 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);
}
示例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: 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);
}
示例7: 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();
}
示例8: 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;
}
}
示例9: doShare
import com.tencent.tauth.Tencent; //導入方法依賴的package包/類
@Override
public void doShare(ShareModel model, Context context, int type, IShareCallback callback) {
this.model = model;
this.context = (Activity) context;
this.callback = callback;
this.mTencent = Tencent.createInstance(ShareConfig.QQ_APP_KEY, context.getApplicationContext());
//0---QQ好友 1---QQ空間
switch (type){
case 0:
QQShare();
break;
case 1:
QQZone();
break;
}
}
示例10: 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;
}
示例11: QQLoginInstance
import com.tencent.tauth.Tencent; //導入方法依賴的package包/類
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();
}
};
}
示例12: QQLoginManager
import com.tencent.tauth.Tencent; //導入方法依賴的package包/類
public QQLoginManager(Context context) {
mContext = context;
mAppId = ShareBlock.getInstance().getQQAppId();
if (!TextUtils.isEmpty(mAppId)) {
mTencent = Tencent.createInstance(mAppId, context);
}
}
示例13: QQShareManager
import com.tencent.tauth.Tencent; //導入方法依賴的package包/類
public QQShareManager(Context context) {
mAppId = ShareBlock.getInstance().getQQAppId();
mContext = context;
if (!TextUtils.isEmpty(mAppId)) {
mTencent = Tencent.createInstance(mAppId, context);
mQQShare = new QQShare(context, mTencent.getQQToken());
}
}
示例14: initTencent
import com.tencent.tauth.Tencent; //導入方法依賴的package包/類
protected boolean initTencent() {
Log.d("", "#### qzone app id = " + this.mAppID);
this.mTencent = Tencent.createInstance(this.mAppID, this.mContext);
if (this.mTencent != null) {
return true;
}
Log.e(TAG, "Tencent變量初始化失敗,請檢查你的app id跟AndroidManifest.xml文件中AuthActivity的scheme是否填寫正確");
return false;
}
示例15: getTencentInstance
import com.tencent.tauth.Tencent; //導入方法依賴的package包/類
public static Tencent getTencentInstance(Context context, String appId) {
if (tencent == null) {
tencent = Tencent.createInstance(appId, context);
}
return tencent;
}