Login interface
The demo of the account-related interface is in TestAccount.java
##Authorization query
Interface description:To determine whether the user is authorized, this interface immediately returns the current authorization status. If you are not authorized, you can call the login authorization interface.
Preconditions: None
Function prototype:public static boolean isAuth()
Parameter description: None
Request example: AliTvSdk.Account.isAuth()
Login authorization interface
Interface description:
This interface will call up the login or authorization page . If you are not logged in, a login box will pop up; if you are logged in but not authorized, an authorization box will pop up. If authorized, return true immediately. This interface will call the account service program of the box, which may take 0.2 to 1 second or longer depending on the network conditions. If you do not want to initiate authorization, but only determine whether it has been authorized, please use the query interface of 2.3.1Precondition: None
Function prototype:public static boolean checkAuthAndLogin()
Parameter description: None
Request example:
public static void checkAuthAndLogin() { boolean isAuth = AliTvSdk.Account.checkAuthAndLogin(); if (isAuth) { TestToast.show("用户已授权"); } else { TestToast.show("用户未授权,请扫码登陆"); } };
Get user information
Interface description:
Get logged in user information, asynchronous callback. The return value includes user NickName, user avatar, user ID, and user points. Please note that by default, the system does not return NickName and user avatar. Users can directly enter the application after logging in. If you need to return NickName and user avatar, please contact the operation configuration. At the same time, the account authorization page will be displayed when the user logs in, and the application will be applied after the user confirms authorization. It is possible to obtain the NickName and user avatar, but the user cannot obtain this information without authorization.Precondition: Authorization is required, if not authorized, an unauthorized error code will be returned
Function prototype:
public static void getUserInfo(IGetUserinfoListener infoListener)Parameter description:
nfoListener receive callbackpublic interface IGetUserinfoListener { public void onSuccess(BaodianUserInfo userInfo); public void onError(int errCode); }
Request example :
AliTvSdk.Account.getUserInfo(new IGetUserinfoListener() { @Override public void onSuccess(UserInfo userInfo) { Log.d(TAG, "userinfo nick:" + userInfo.getUserNick() + ", id:" + userInfo.getUserId() + " headUrl:"+userInfo.getAvatarUrl()); TestToast.show("nick:" + userInfo.getUserNick() + ", id:" + userInfo.getUserId() + " headUrl:"+userInfo.getAvatarUrl()); } @Override public void onError(int errCode) { LogUtils.d(TAG, "get userinfo error:" + errCode + " " + AliBaseError.getErrMsg(errCode)); TestToast.show(AliBaseError.getErrMsg(errCode) + "====="); } });