Android Open Source - ABTester Splash Activity






From Project

Back to project page ABTester.

License

The source code is released under:

MIT License

If you think the Android project ABTester listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.ab_sample;
/*from  w w w.j  ava 2 s  . co m*/
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import ab.tester.ABTest;
import ab.tester.ABTester;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;

public class SplashActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    ABTester.init(this, "public", "private");
    
    ExecutorService ex = Executors.newSingleThreadExecutor();
    ex.execute(new Runnable() {
      @Override
      public void run() {
        int msTimeout = (int)TimeUnit.SECONDS.toMillis(15);
        long start = SystemClock.uptimeMillis();
        try {
          // We will pull the vars TITLE, WANT_BTN and DONT_WANT_BTN with lock set to FALSE - thats mean that those vars can be modified 
          // from the exp dashboard
          ABTester.syncPreFetch(msTimeout, new ABTest("SampleProject", false, "TITLE", "WANT_BTN", "DONT_WANT_BTN"));
          Log.v("ABTesterSample", "synced within " + (SystemClock.uptimeMillis() - start) + "ms");
        } catch (TimeoutException e) {
          Log.v("ABTesterSample", "timed out with " + msTimeout);
        }
        
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();
      }
    });
    ex.shutdown();
  }
  
  @Override
  protected void onPause() {
    super.onPause();
    ABTester.submitEvents();
  }
}




Java Source Code List

ab.tester.ABTest.java
ab.tester.ABTester.java
ab.tester.DefualtLogger.java
ab.tester.LoggerInterface.java
ab.tester.prefs.ABEventsSharedPrefs.java
ab.tester.prefs.ABGeneralSharedPrefs.java
ab.tester.prefs.ABSharedPrefs.java
ab.tester.prefs.ABTestsSharedPrefs.java
com.example.ab_sample.MainActivity.java
com.example.ab_sample.SplashActivity.java