狐的传说
我已经开发了一个Android试用版SDK,您可以将其轻松放入Android Studio项目中,它将为您处理所有服务器端管理(包括离线宽限期)。要使用它,只需将库添加到主模块的 build.gradledependencies { compile 'io.trialy.library:trialy:1.0.2'}用您的主要活动的onCreate()方法初始化库@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Initialize the library and check the current trial status on every launch Trialy mTrialy = new Trialy(mContext, "YOUR_TRIALY_APP_KEY"); mTrialy.checkTrial(TRIALY_SKU, mTrialyCallback);}添加一个回调处理程序:private TrialyCallback mTrialyCallback = new TrialyCallback() { @Override public void onResult(int status, long timeRemaining, String sku) { switch (status){ case STATUS_TRIAL_JUST_STARTED: //The trial has just started - enable the premium features for the user break; case STATUS_TRIAL_RUNNING: //The trial is currently running - enable the premium features for the user break; case STATUS_TRIAL_JUST_ENDED: //The trial has just ended - block access to the premium features break; case STATUS_TRIAL_NOT_YET_STARTED: //The user hasn't requested a trial yet - no need to do anything break; case STATUS_TRIAL_OVER: //The trial is over break; } Log.i("TRIALY", "Trialy response: " + Trialy.getStatusMessage(status)); }};要开始试用,请致电mTrialy.startTrial("YOUR_TRIAL_SKU", mTrialyCallback); 您的应用密钥,然后在Trialy开发人员仪表板中找到试用SKU 。