當前位置: 首頁>>代碼示例>>Java>>正文


Java Tencent類代碼示例

本文整理匯總了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);
        }
    };
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:MainActivity.java

示例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;
    }


}
 
開發者ID:penghuanliang,項目名稱:Rxjava2.0Demo,代碼行數:17,代碼來源:LoginActivity.java

示例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;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:17,代碼來源:BaseDialog.java

示例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);

}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:26,代碼來源:QQShareApi.java

示例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);
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:19,代碼來源:QQShareApi.java

示例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);
    }
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:25,代碼來源:QQShareApi.java

示例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);
}
 
開發者ID:pinguo-sunjianfei,項目名稱:Android-Application-ZJB,代碼行數:27,代碼來源:ShareModel.java

示例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);
	}
}
 
開發者ID:bigthing33,項目名稱:LoginDemo,代碼行數:17,代碼來源:MainActivity.java

示例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();
}
 
開發者ID:leleliu008,項目名稱:Newton_for_Android_AS,代碼行數:27,代碼來源:ShareUtils.java

示例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();
}
 
開發者ID:x251089003,項目名稱:EveryXDay,代碼行數:24,代碼來源:ToolbarControlDetailListViewActivity.java

示例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();
	}
}
 
開發者ID:liuling07,項目名稱:QiQuYing,代碼行數:24,代碼來源:QuShiDetailActivity.java

示例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();
	}
}
 
開發者ID:liuling07,項目名稱:QiQuYing,代碼行數:29,代碼來源:TencentUtils.java

示例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;
}
 
開發者ID:fatsoon,項目名稱:UniversalCommunityAccount,代碼行數:17,代碼來源:UCAQqUtils.java

示例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;
    }
}
 
開發者ID:LightSun,項目名稱:android-common-utils,代碼行數:20,代碼來源:QQHelper.java

示例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;
    }
}
 
開發者ID:rantianhua,項目名稱:ShuTuier,代碼行數:18,代碼來源:SettingFragment.java


注:本文中的com.tencent.tauth.Tencent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。