我如何知道有多少用户在android应用程序或网站中登录谷歌?

我如何知道有多少用户在android应用程序或网站中登录谷歌?,android,google-signin,Android,Google Signin,如果我在android中添加了谷歌登录 有什么方法可以知道有多少用户在android应用程序或网站中登录谷歌 我想知道谷歌是否成功登录。如果用户被拒绝并取消授予权限,我认为如果用户被取消授予权限且未批准与谷歌签署的权限,谷歌分析将显示一次点击 我能看穿吗 仪表板->流量、错误的含义是什么 它显示了什么数据?将谷歌分析添加到您的android应用程序中,并跟踪预期事件。请跟随 在您的情况下,此时跟踪事件或将数据发布到web服务器: @Override protected vo

如果我在android中添加了谷歌登录

有什么方法可以知道有多少用户在android应用程序或网站中登录谷歌


我想知道谷歌是否成功登录。如果用户被拒绝并取消授予权限,我认为如果用户被取消授予权限且未批准与谷歌签署的权限,谷歌分析将显示一次点击

我能看穿吗

仪表板->流量、错误的含义是什么


它显示了什么数据?

将谷歌分析添加到您的android应用程序中,并跟踪预期事件。请跟随

在您的情况下,此时跟踪事件或将数据发布到web服务器:

   @Override
       protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from
    //   GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        //Google44
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
     //Post or track here
  }
 }
}

对于Android应用程序,u可以使用下面的util类来显示Android设备中的所有登录用户

公共类GooglePlusUtil实现GoogleAppClient.OnConnectionFailedListener{

public static final int RC_SIGN_IN = 007;
public static final int G_LOGIN_CANCELLED = 12051;

private int userIdCounter = 0;
private Context mContext;
private GoogleApiClient mGoogleApiClient;
private FragmentActivity mFragmentActivity;
private GoogleResponse mResponseListener;

/**
 * Instantiates a new Google util.
 *
 * @param context
 * @param activity        the context
 * @param signInPresenter
 */
public GooglePlusUtil(Context context, FragmentActivity activity, SignInPresenter signInPresenter) {
    mContext = context;
    mFragmentActivity = activity;
    mResponseListener = signInPresenter;
    initGPlus();
}

private void initGPlus() {
    // Configure sign-in to request the user's ID, email address, and basic
    // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();

    // Build a GoogleApiClient with access to the Google Sign-In API and the
    // options specified by gso.
    mGoogleApiClient = new GoogleApiClient.Builder(mContext)
            .enableAutoManage(mFragmentActivity, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
}

/**
 * Call G+ login activity.
 */
public void login() {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    mFragmentActivity.startActivityForResult(signInIntent, RC_SIGN_IN);
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Crashlytics.log(connectionResult.toString());
    Log.d("ConnectionResult", "G+ " + connectionResult.toString());
}

/**
 * Parse G+ response.
 *
 * @param accountsByType account number id
 * @param acct           G+ response.
 */
public void findAuth(Account[] accountsByType, GoogleSignInAccount acct) {
    matchAccountNumber(accountsByType, acct);
    new GoogleAsyncTask(accountsByType, acct).execute();
}

/**
 * userIdCounter Account Number
 *
 * @param accounts account number id
 * @param acct     G+ response.
 */
private void matchAccountNumber(Account[] accounts, GoogleSignInAccount acct) {
    for (int index = 0; index < accounts.length; index++) {
        if (accounts[index].name.equals(acct.getEmail())) {
            userIdCounter = index;
            break;
        }
    }
}

/**
 * Google login response.
 *
 * @param result G+ instance.
 */
public void handleSignInResult(GoogleSignInResult result) {
    if (result.isSuccess()) {
        GoogleSignInAccount acct = result.getSignInAccount();
        if (acct == null || ActivityCompat.checkSelfPermission(mContext, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
            return;
        }
        findAuth(AccountManager.get(mContext).getAccountsByType("com.google"), acct);

    } else if (result.getStatus().getStatusCode() == G_LOGIN_CANCELLED) {
        ToastUtils.getInstance(mContext).showToast(mContext.getString(R.string.google_login_cancelled));
    } else {
        ToastUtils.getInstance(mContext).showToast(mContext.getString(R.string.message_not_able_to_login_via_google));
    }
}

public class GoogleAsyncTask extends AsyncTask<Void, Void, String> {
    private Account[] mAccountsByType;
    private GoogleSignInAccount mGoogleSignInAccount;

    /**
     * Instantiates a new Google async task.
     *
     * @param accountsByType
     * @param acct
     */
    public GoogleAsyncTask(Account[] accountsByType, GoogleSignInAccount acct) {
        mAccountsByType = accountsByType;
        mGoogleSignInAccount = acct;
    }

    @Override
    protected String doInBackground(Void... params) {
        try {
            return GoogleAuthUtil.getToken(mContext, mAccountsByType[userIdCounter], Constants.OAUTH_URL);
        } catch (UserRecoverableAuthException e) {
            Crashlytics.logException(e.getCause());
            AppLogger.e(e);
            mResponseListener.onTokenNotFound(e.getIntent(), RC_SIGN_IN);
        } catch (GoogleAuthException | IOException e) {
            Crashlytics.logException(e.getCause());
            AppLogger.e(e);
        }
        return "";
    }

    @Override
    protected void onPostExecute(String token) {
        IsAuthValidRequest isAuthValidRequest = new IsAuthValidRequest();
        isAuthValidRequest.setEmail(mGoogleSignInAccount.getEmail());
        isAuthValidRequest.setFirstName(mGoogleSignInAccount.getDisplayName());
        isAuthValidRequest.setLastName(mGoogleSignInAccount.getFamilyName());
        mResponseListener.onGoogleUserInfoAvailable(isAuthValidRequest, token);
    }
}

public interface GoogleResponse {

    /**
     * When user info and token found.
     *
     * @param isAuthValidRequest info instance.
     * @param token G+.
     */
    void onGoogleUserInfoAvailable(IsAuthValidRequest isAuthValidRequest, String token);

    /**
     * Invoke when auth token not found.
     *
     * @param intent      instance.
     * @param requestCode request code.
     */
    void onTokenNotFound(Intent intent, int requestCode);
}
public static final int RC\u SIGN\u IN=007;
公共静态最终int G_登录被取消=12051;
私有int userIdCounter=0;
私有上下文;
私人GoogleapClient MGoogleapClient;
私人碎片活动;
私人谷歌回应mResponseListener;
/**
*实例化一个新的googleutil。
*
*@param上下文
*@param-activity上下文
*@param signInPresenter
*/
公共GooglePlusUtil(上下文上下文、碎片活动活动、SignInPresenter SignInPresenter){
mContext=上下文;
mFragmentActivity=活动;
mResponseListener=signInPresenter;
initGPlus();
}
私有void initGPlus(){
//配置登录以请求用户ID、电子邮件地址和基本信息
//配置文件。ID和基本配置文件包含在默认登录中。
GoogleSignenOptions gso=新建GoogleSignenOptions.Builder(GoogleSignenOptions.DEFAULT\u登录)
.requestEmail()
.build();
//通过访问Google登录API和
//gso指定的选项。
mgoogleapclient=新的Googleapclient.Builder(mContext)
.enableAutomanaged(mFragmentActivity,this)
.addApi(Auth.GOOGLE\u SIGN\u IN\u API,gso)
.build();
}
/**
*调用G+登录活动。
*/
公共无效登录(){
意向符号=Auth.googlesignianpi.getsignient(mgoogleapclient);
M碎片活动性。startActivityForResult(重要,RC_签到);
}
@凌驾
public void onconnection失败(@NonNull ConnectionResult ConnectionResult){
log(connectionResult.toString());
Log.d(“ConnectionResult”,“G+”+ConnectionResult.toString());
}
/**
*解析G+响应。
*
*@param accountsByType帐号id
*@param acct G+响应。
*/
公共作废findAuth(账户[]账户ByType,谷歌签名账户){
匹配AccountNumber(accountsByType,acct);
新任务(accountsByType,acct).execute();
}
/**
*userIdCounter帐号
*
*@param帐户帐号id
*@param acct G+响应。
*/
私有无效匹配账号(账号[]账号,谷歌签名账号){
对于(int index=0;index