33
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package cn.shangyu.gdxzExpert.umeng;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.umeng.umverify.UMResultCode;
|
||||
import com.umeng.umverify.UMVerifyHelper;
|
||||
import com.umeng.umverify.listener.UMTokenResultListener;
|
||||
import com.umeng.umverify.model.UMTokenRet;
|
||||
|
||||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||||
|
||||
public class UverifyHelp {
|
||||
private static final String TAG = "UverifyHelp";
|
||||
private static UMTokenResultListener mTokenResultListener;
|
||||
private static UMVerifyHelper mPhoneNumberAuthHelper;
|
||||
public static void sdkInit() {
|
||||
mTokenResultListener = new UMTokenResultListener() {
|
||||
@Override
|
||||
public void onTokenSuccess(String s) {
|
||||
|
||||
UMTokenRet tokenRet = null;
|
||||
try {
|
||||
tokenRet = UMTokenRet.fromJson(s);
|
||||
if (UMResultCode.CODE_START_AUTHPAGE_SUCCESS.equals(tokenRet.getCode())) {
|
||||
Log.i("TAG", "唤起授权页成功:" + s);
|
||||
}
|
||||
|
||||
if (UMResultCode.CODE_GET_TOKEN_SUCCESS.equals(tokenRet.getCode())) {
|
||||
Log.i("TAG", "获取token成功:" + s);
|
||||
// getResultWithToken(tokenRet.getToken());
|
||||
// mUIConfig.release();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTokenFailed(String s) {
|
||||
Log.e(TAG, "获取token失败:" + s);
|
||||
|
||||
UMTokenRet tokenRet = null;
|
||||
mPhoneNumberAuthHelper.quitLoginPage();
|
||||
try {
|
||||
tokenRet = UMTokenRet.fromJson(s);
|
||||
if (UMResultCode.CODE_ERROR_USER_CANCEL.equals(tokenRet.getCode())) {
|
||||
//模拟的是必须登录 否则直接退出app的场景
|
||||
// finish();
|
||||
} else {
|
||||
Toast.makeText(UIUtils.getContext(), "一键登录失败切换到其他登录方式", Toast.LENGTH_SHORT).show();
|
||||
// Intent pIntent = new Intent(OneKeyLoginActivity.this, MessageActivity.class);
|
||||
// startActivityForResult(pIntent, 1002);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// mUIConfig.release();
|
||||
}
|
||||
};
|
||||
mPhoneNumberAuthHelper = UMVerifyHelper.getInstance(UIUtils.getContext(), mTokenResultListener);
|
||||
mPhoneNumberAuthHelper.setAuthSDKInfo("请开发者自行添加");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user