本文整理汇总了Java中com.tencent.mm.sdk.modelmsg.SendAuth类的典型用法代码示例。如果您正苦于以下问题:Java SendAuth类的具体用法?Java SendAuth怎么用?Java SendAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SendAuth类属于com.tencent.mm.sdk.modelmsg包,在下文中一共展示了SendAuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleIntent
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
private void handleIntent(Intent intent) {
if (intent == null) {
return;
}
SendAuth.Resp resp = new SendAuth.Resp(intent.getExtras());
if (resp.errCode == BaseResp.ErrCode.ERR_OK) {
//用户同意
String code = resp.code;
String state = resp.state;
// 如果不是登录
if (!"wechat_login".equals(state)) {
finish();
} else {
//上面的code就是接入指南里要拿到的code
getAccessTokenAndOpenId(code);
}
} else {
finish();
}
}
示例2: login
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public void login(Callback callback) {
IWXAPI iwxapi = init();
if (iwxapi == null) {
if (callback != null)
callback.onFailed();
return;
}
// 唤起微信登录授权
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "wechat_login";
// 失败回调
if (!iwxapi.sendReq(req) && callback != null) {
callback.onFailed();
} else {
if (callback != null)
callback.onSuccess();
}
}
示例3: onClick
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_wx_login:
if (MyApplication.isInstallWx) {
btn_login.setText(R.string.wx_logining);
SendAuth.Req req = new SendAuth.Req();
req.scope = getString(R.string.scope);
req.state = getString(R.string.state);
MyApplication.api.sendReq(req);
} else {
CommonUtils.showToast(getApplicationContext(), getString(R.string.wx_not_install));
}
break;
case R.id.tv_protocol:
Intent intent = new Intent(IndexActivity.this, ProtocolActivity.class);
startActivity(intent);
break;
}
}
示例4: requestOauthCode
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
/**
* 第一步、获得授权的code
*/
public void requestOauthCode(IWXListener listener, String transaction) {
if (!WXAPI.isWXAppInstalled()) {
if (listener != null) {
listener.wxUnInstall();
}
return;
}
//1.生成一个此链接的唯一标识,返回的时候会原封不动地返回回来
Random random = new Random();
int value = random.nextInt(1000) + 1;
mTransaction = transaction;
String state = mTransaction + value;
//2.发出请求,获取code
final SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = state;
req.transaction = mTransaction;
WXAPI.sendReq(req);
}
示例5: onCreate
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_login);
ButterKnife.inject(this);
//1.初始化model
mViewModel = new LoginModel();
//2.注册RxBus(请求Oauth_code时候的回调)
RxBusManager.register(this, EventConstant.KEY_WX_OAUTH_CODE, WeiXinEvent.LoginEvent.class)
.subscribe(resp -> {
SendAuth.Resp response = resp.getData();
if (SendAuth.Resp.ErrCode.ERR_OK == response.errCode) {
Observable<WChatLoginInfo> observable = WChatManager.getInstance().login(response.code);
Subscription subscription = observable.subscribe(this::onWChatAuthorizeNext, this::onWChatError);
addSubscription(subscription);
} else {
setLoginBtnStatus(false);
}
}, Logger::e);
}
示例6: login
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void login(final Activity activity, Bundle pararms, final LoginCallback callback) {
DebugLog.d(TAG, "login()");
this.callback = callback;
IWXAPI wxapi = MyApp.getApp().getWXAPI();
if (!wxapi.isWXAppInstalled()) {
//提醒用户没有安装微信
String uninstalled = activity.getResources().getString(R.string.WeixinLogin_uninstalled);
CustomToast.makeText(activity,uninstalled, 2000).show();
return;
}
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "wechat_sdk_demo";
wxapi.sendReq(req);
}
示例7: onWechatLogin
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
/**
* 微信授权登录
*/
@Click(R.id.llWechatLogin)
void onWechatLogin() {
/* Log.i("LoginActivity", "微信授权登录");
//AbToastUtil.showToast(mContext,"功能正在完善开发中...");
Config.dialog = ProgressDialog.show(mContext, "提示", "正在请求跳转....");
SHARE_MEDIA platform = SHARE_MEDIA.WEIXIN;
umShareAPI = UMShareAPI.get(mContext);
umShareAPI.doOauthVerify(this, platform, umAuthListener);*/
if (Contact.isWeixinAvilible(this)) {
progressDialog = AbDialogUtil.showProgressDialog(mContext, Global.LOADING_PROGRESSBAR_ID, "登录中");
mLlWechatLogin.setEnabled(false);
IWXAPI api = WXAPIFactory.createWXAPI(this, "wx747d053fa471eb15", true);
api.registerApp("wx747d053fa471eb15");
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "wechat_sdk_demo_test";
api.sendReq(req);
} else {
ToastUtils.show(this, "请安装微信");
}
}
示例8: onResp
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onResp(BaseResp resp) {
Log.e(TAG, "onResp...");
Log.i("Apptest", "onResp...");
String code = null;
switch (resp.errCode) {
case BaseResp.ErrCode.ERR_OK:// 用户同意,只有这种情况的时候code是有效的
code = ((SendAuth.Resp) resp).code;
Log.i("Apptest", code);
getResult(code);
break;
case BaseResp.ErrCode.ERR_AUTH_DENIED:// 用户拒绝授权
Log.e("Apptest", "用户拒绝授权");
break;
case BaseResp.ErrCode.ERR_USER_CANCEL:// 用户取消
Log.e("Apptest", "用户取消");
break;
default:// 发送返回
break;
}
finish();
}
示例9: login
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
/**
* 发出登陆请求
* @param context
*/
public static void login(Context context) {
if (!isWXAPPInstalled(context)) {
Helper.showToast("请安装微信客户端");
} else {
if (!mWXAPI.isWXAppSupportAPI()) {
Helper.showToast( "请升级微信客户端,不支持api!");
} else {
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "none";
mWXAPI.sendReq(req);
}
}
}
示例10: authComplete
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public static void authComplete(SendAuth.Resp resp) {
switch (resp.errCode) {
case BaseResp.ErrCode.ERR_OK:
callback.onGetCodeSuccess(resp.code);
break;
case BaseResp.ErrCode.ERR_USER_CANCEL:
callback.onCancel();
break;
case BaseResp.ErrCode.ERR_AUTH_DENIED:
callback.onFailure(new Exception("BaseResp.ErrCode.ERR_AUTH_DENIED"));
break;
}
}
示例11: onResp
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onResp(BaseResp resp) {
if (resp instanceof SendAuth.Resp)
WeChatSSOProxy.authComplete((SendAuth.Resp) resp);
else if (resp instanceof SendMessageToWX.Resp)
WeChatShareProxy.shareComplete((SendMessageToWX.Resp) resp);
finish();
}
示例12: doLogin
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void doLogin(Activity activity, LoginListener listener, boolean fetchUserInfo) {
final SendAuth.Req req = new SendAuth.Req();
req.scope = SCOPE_USER_INFO;
req.state = String.valueOf(System.currentTimeMillis());
mIWXAPI.sendReq(req);
}
示例13: handleResult
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void handleResult(int requestCode, int resultCode, Intent data) {
mIWXAPI.handleIntent(data, new IWXAPIEventHandler() {
@Override
public void onReq(BaseReq baseReq) {
}
@Override
public void onResp(BaseResp baseResp) {
if (baseResp instanceof SendAuth.Resp && baseResp.getType() == 1) {
SendAuth.Resp resp = (SendAuth.Resp) baseResp;
switch (resp.errCode) {
case BaseResp.ErrCode.ERR_OK:
getToken(resp.code);
break;
case BaseResp.ErrCode.ERR_USER_CANCEL:
mLoginListener.loginCancel();
break;
case BaseResp.ErrCode.ERR_SENT_FAILED:
mLoginListener.loginFailure(new Exception(INFO.WX_ERR_SENT_FAILED));
break;
case BaseResp.ErrCode.ERR_UNSUPPORT:
mLoginListener.loginFailure(new Exception(INFO.WX_ERR_UNSUPPORT));
break;
case BaseResp.ErrCode.ERR_AUTH_DENIED:
mLoginListener.loginFailure(new Exception(INFO.WX_ERR_AUTH_DENIED));
break;
default:
mLoginListener.loginFailure(new Exception(INFO.WX_ERR_AUTH_ERROR));
}
}
}
});
}
示例14: login
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public static void login(Context context, IWXCallback callback, SocialInfo info) {
if (!SocialSSOProxy.isTokenValid(context)) {
WeChatSSOProxy.callback = callback;
SendAuth.Req req = new SendAuth.Req();
req.scope = info.getWeChatScope();
WeChat.getIWXAPIInstance(context, info.getWechatAppId()).sendReq(req);
}
}
示例15: auth
import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void auth(Activity activity) {
ShareType = ShareConstant.AUTH;
api = WXAPIFactory.createWXAPI(activity, BuildConfig.WECHAT_APP_ID, true);
api.registerApp(BuildConfig.WECHAT_APP_ID);
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "mengwo_wx_login";
api.sendReq(req);
}