0

如果您想让 Beta 测试人员测试最终将成为付费应用的应用怎么办?如果您不想使用 Google API,例如检查 Gmail 帐户,该怎么办?

4

2 回答 2

0

请注意,这不适用于通过 Google 发布 Beta。是为了自己做。

我现在正在测试一系列中文课程应用程序,并决定使用电话号码让测试人员访问。请注意,您不能总是从电话设备中获取电话号码。但大多数情况下你可以。这是进行检查的类:

package org.this_voice.ruzhechu01;

import android.telephony.TelephonyManager;
import android.content.Context;
import java.util.Set;
import java.util.HashSet;
import java.util.Arrays;


public class BetaPhoneCheck extends Object {

private String accessGranted = "false";
private Context appContext = null;
private static final Set<String> ACCESS_LIST = new HashSet<String> (Arrays.asList(
    new String[] {"2074583598"}));

public BetaPhoneCheck(Context context) {
    appContext = context;
}


public boolean hasAccess(){
    String thisNumber = getDevicePhoneNumber();
    thisNumber = thisNumber.replace("-", ""); //FIXME use fhandler's regex code
    return ACCESS_LIST.contains(thisNumber);
}


/*
 * not guaranteed to work...
 */
private String getDevicePhoneNumber() {
    TelephonyManager mTelephonyMgr;
    mTelephonyMgr = (TelephonyManager)
        appContext.getSystemService(Context.TELEPHONY_SERVICE);
    return mTelephonyMgr.getLine1Number();
}   

}

这是访问失败的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<TextView
    android:id="@+id/title"
    style="?textTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/app_name" />

<TextView
    android:id="@+id/textView1"
    style="?textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/no_access" />

<Button
    style="?button"
    android:id="@+id/accessExit"
    android:layout_width="fill_parent"
    android:layout_height="36dp"
    android:text="Exit"
    android:onClick="exit" />


</LinearLayout>

这是strings.xml:

<string name="no_access">BETA ACCESS FAILURE\n\nMake sure your phone is in service.\n\nEmail developer if you are unable to access your Beta App.\n\n</string>

这是主要活动的 onCreate 代码:

    boolean hasAccess = new BetaPhoneCheck(this).hasAccess();

    if (! hasAccess){
        setContentView(R.layout.no_access);
    } else {

清单的烫发:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

希望这可以在人们想要将应用程序推出测试版时节省一些时间。享受。

于 2013-08-19T14:44:27.220 回答
0

我要求人们通过电子邮件向我发送他们的 UUID 并在启动活动中检查 UUID。但是,这并不能扩展到大量用户。如果您想这样做,您将需要一个 Web 服务来检查 UUID 与数据库中允许的 id 列表。

于 2013-08-19T14:47:40.943 回答