Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Note that this is NOT for releasing Beta through Google. It's for doing it on your own. </p> <p>I'm beta testing a series of Chinese lesson apps right now and decided to use phone numbers to allow beta testers access. Note that you cannot always get a phone number from a phone device. But mostly you can. Here's the class that does the checking:</p> <pre><code>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&lt;String&gt; ACCESS_LIST = new HashSet&lt;String&gt; (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(); } } </code></pre> <p>Here's a layout for access failure:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/title" style="?textTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/app_name" /&gt; &lt;TextView android:id="@+id/textView1" style="?textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_access" /&gt; &lt;Button style="?button" android:id="@+id/accessExit" android:layout_width="fill_parent" android:layout_height="36dp" android:text="Exit" android:onClick="exit" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Here's for strings.xml:</p> <pre><code>&lt;string name="no_access"&gt;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&lt;/string&gt; </code></pre> <p>And here's the onCreate code from the main activity:</p> <pre><code> boolean hasAccess = new BetaPhoneCheck(this).hasAccess(); if (! hasAccess){ setContentView(R.layout.no_access); } else { </code></pre> <p>And the perm for the manifest:</p> <pre><code>&lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt; </code></pre> <p>Hope this saves people some time when they want to push apps out to beta. Enjoy.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload