Last active
November 22, 2021 19:48
-
-
Save mauerbac/64d2c638b72e38de603f511601dd2b91 to your computer and use it in GitHub Desktop.
Full code snippet for Optimizely's Android Getting Started Guide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MainActivity.java | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.widget.Toast; | |
import com.optimizely.ab.android.sdk.OptimizelyClient; | |
import com.optimizely.ab.android.sdk.OptimizelyManager; | |
import com.optimizely.ab.android.sdk.OptimizelyStartListener; | |
import com.optimizely.ab.config.Variation; | |
import java.util.concurrent.TimeUnit; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
OptimizelyManager optimizelyManager = OptimizelyManager.builder("project_id") | |
.withEventHandlerDispatchInterval(30, TimeUnit.SECONDS) | |
.withDataFileDownloadInterval(30, TimeUnit.SECONDS) | |
.build(); | |
optimizelyManager.initialize(this, new OptimizelyStartListener() { | |
@Override | |
public void onStart(OptimizelyClient optimizely) { | |
Variation variation = optimizely.activate("my_experiment", "currentUser"); | |
System.out.println(variation); | |
optimizely.track("my_conversion", "currentUser"); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
will the initialization process not make the onCreate of the Activity to run slow?