<commit_before>.. meta::
   :description: Android A/B testing client setup

Arise Android SDK
*****************

This documentation will help you to install the Arise Android client in your application.

Installation steps
==================

1. Add the Arise library to your project
----------------------------------------

First, download the `Arise library jar file`_ and drag it inside your project's /libs/ folder.

.. _`Arise library jar file`: https://s3.amazonaws.com/ariseio/Arise-Android-2.3.jar

2. Add permissions
-------------------

In your project, right click on AndroidManifest.xml Click on Open With/Android Common XML Editor. Add after the <uses-sdk .... /> tag:

.. code-block:: xml

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

3. Initialize the framework
---------------------------

In the onCreate function of your main activity, you need to initialize the framework:

.. code-block:: java

    // Initialize the arise library
    String authKey = "9c51b5e8f06ebd26728f29954365098f052c68c8";
    Arise.initialize(getApplicationContext(), authKey);

Replace the value of authKey by your own key. You can find in your dashboard.

4. Get the experiment value
---------------------------

When you plan to run the experiment, you will need to call the getVariationWithListener with the experiment name (same as the one displayed in your dashboard) to get the experiment data:

.. code-block:: java

    // Get and setup the variation
    ABTest.getVariationWithListener("Experiment1", VariationListener() {
    	@Override
    	public void onVariationAvailable(String value) {
    		final String buyMessage = value;
    	}
    });

5. Record events
----------------

Now that you have setup your application for testing, you will need to record views and conversion events. You need to pass the experiment name as a parameter to associate the events with an experiment.

Record a view:

.. code-block:: java

	ABTest.recordView("Experiment1");

Record a conversion:

.. code-block:: java

	ABTest.recordConversion("Experiment1");


Full code example
==================

.. code-block:: java

    package com.example.shoestore;

    import io.arise.ABTest;
    import io.arise.Arise;
    import io.arise.VariationListener;
    import android.os.Bundle;
    import android.app.Activity;

    public class MainActivity extends Activity {

    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);

    		// Initialize the arise library
    		String authKey = "9c51b5e8f06ebd26728f29954365098f052c68c8";
    		Arise.initialize(getApplicationContext(), authKey);

    		// Get and setup the variation
    		ABTest.getVariationWithListener("Experiment1", new VariationListener() {
    			@Override
    			public void onVariationAvailable(String value) {
    				// Change the button label
    				final String buyMessage = value;
    				// Use the buyMessage to customize our application
    				// ...

    			}
    		});

    	}

    	private void onLoadPurchasePage(){
    		// the user is viewing the item purchase page
    		// record a view event
    		ABTest.recordView("Experiment1");
    	}
<commit_msg>Update android.rst<commit_after>.. meta::
   :description: Android A/B testing client setup

Arise Android SDK
*****************

This documentation will help you to install the Arise Android client in your application.

Installation steps
==================

1. Add the Arise library to your project
----------------------------------------

First, download the `Arise library jar file`_ and drag it inside your project's /libs/ folder.

.. _`Arise library jar file`: https://s3.amazonaws.com/ariseio/Arise-Android-2.3.jar

2. Add permissions
-------------------

In your project, right click on AndroidManifest.xml Click on Open With/Android Common XML Editor. Add after the <uses-sdk .... /> tag:

.. code-block:: xml

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

3. Initialize the framework
---------------------------

In the onCreate function of your main activity, you need to initialize the framework:

.. code-block:: java

    // Initialize the arise library
    String authKey = "9c51b5e8f06ebd26728f29954365098f052c68c8";
    Arise.initialize(getApplicationContext(), authKey);

Replace the value of authKey by your own key. You can find in your dashboard.

4. Get the experiment value
---------------------------

When you plan to run the experiment, you will need to call the getVariationWithListener with the experiment name (same as the one displayed in your dashboard) to get the experiment data.
You can also set a default value in case of no connection from the server.

.. code-block:: java

    // Get and setup the variation
    ABTest.getVariationWithListener("Experiment1", "default value", new VariationListener() {
    	@Override
    	public void onVariationAvailable(String value) {
    		final String buyMessage = value;
    	}
    });

5. Record events
----------------

Now that you have setup your application for testing, you will need to record views and conversion events. You need to pass the experiment name as a parameter to associate the events with an experiment.

Record a view:

.. code-block:: java

	ABTest.recordView("Experiment1");

Record a conversion:

.. code-block:: java

	ABTest.recordConversion("Experiment1");


Full code example
==================

.. code-block:: java

    package com.example.shoestore;

    import io.arise.ABTest;
    import io.arise.Arise;
    import io.arise.VariationListener;
    import android.os.Bundle;
    import android.app.Activity;

    public class MainActivity extends Activity {

    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);

    		// Initialize the arise library
    		String authKey = "9c51b5e8f06ebd26728f29954365098f052c68c8";
    		Arise.initialize(getApplicationContext(), authKey);

    		// Get and setup the variation
    		ABTest.getVariationWithListener("Experiment1", "default value", new VariationListener() {
    			@Override
    			public void onVariationAvailable(String value) {
    				// Change the button label
    				final String buyMessage = value;
    				// Use the buyMessage to customize our application
    				// ...

    			}
    		});

    	}

    	private void onLoadPurchasePage(){
    		// the user is viewing the item purchase page
    		// record a view event
    		ABTest.recordView("Experiment1");
    	}

{'fraction_non_alphanumeric': 0.12860576923076922, 'fraction_numerical': 0.021334134615384616, 'mean_word_length': 2.8546612623045746, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3478946', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1809, 'n_words': 643}