用户以某种方式访问​​免费版本的Pro功能 [英] A user is somehow accessing Pro features in the Free version

查看:96
本文介绍了用户以某种方式访问​​免费版本的Pro功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的Flavor名称设置了常量:

I have constants set up for my Flavor names:

public static final String FLAVOR_NAME_PRO = "pro";
public static final String FLAVOR_NAME_FREE = "free";

在我的Activity的onCreate()中,我为布尔mUsingProFlavor分配了一个值:

Inside my Activity's onCreate() I assign the boolean mUsingProFlavor a value:

    mUsingProFlavor = BuildConfig.FLAVOR.equals(FLAVOR_NAME_PRO);

在稍后创建的clickListener中,我有以下内容:

In a clickListener created later on I have this:

if (mUsingProFlavor) {
     customerId = getCustomerId();
     Intent intent = new Intent(MainActivity.this, CustomerProfileActivity.class);
                    intent.putExtra("customerId", customerId);
                    startActivity(intent);
   } else {
        showProOnlyFeatureAlertDialog(MainActivity.this, mAlertDialog);
   }

这是用户访问CustomerProfileActivity的唯一方法,正在收到崩溃报告,表明我的一个免费用户正在CustomerProfileActivity内部崩溃。

This is the only way for the user to access CustomerProfileActivity, and yet somehow I'm getting crash reports indicating that one of my Free users is crashing inside of CustomerProfileActivity.

任何想法怎么可能?

推荐答案

if (mUsingProFlavor) {
 customerId = getCustomerId();
 Intent intent = new Intent(MainActivity.this, CustomerProfileActivity.class);
                intent.putExtra("customerId", customerId);
                startActivity(intent);
 } else {
    showProOnlyFeatureAlertDialog(MainActivity.this, mAlertDialog);
}

您的-> if(mUsingProFlavor)是这里的问题。
因为mUsingProFlavor是一个字符串,所以您必须修改if-check。当前,它充当布尔值。

Your -> if(mUsingProFlavor) is the issue here. Since mUsingProFlavor is a String, you have to modify your if-check. Currently it is acting as boolean.

if (mUsingProFlavor.equals("pro")) {
 customerId = getCustomerId();
 Intent intent = new Intent(MainActivity.this, CustomerProfileActivity.class);
                intent.putExtra("customerId", customerId);
                startActivity(intent);
 } else {
    showProOnlyFeatureAlertDialog(MainActivity.this, mAlertDialog);
}

这篇关于用户以某种方式访问​​免费版本的Pro功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆