Show Menu

Android - set up the mobile app

The Adobe Target Mobile App Visual Experience Composer (VEC) lets developers do a one-time setup on their Android mobile apps and enable marketers to use the capabilities of the Mobile App VEC.
For more information on enabling the Adobe Target VEC extension, see Adobe Target - Visual Experience Composer in the Adobe Experience Platform Mobile SDKs .

Include the Mobile SDK and the Target library

  1. For information about SDK V5 initialization, see Initialize the SDK and Set Up Tracking .
  2. Add the following line to the dependencies section:
    implementation ''
    implementation ''
  3. The Mobile App VEC requires the following artifacts to be included as a dependency in build.gradle .
     implementation 'android.arch.lifecycle:extensions:1.1.1'
     implementation 'io.github.sac:SocketclusterClientJava:1.7.5'
     implementation ''
     implementation ''
  4. Add an intent filter in your AndroidManifest.XML file, choosing a unique deep-link scheme for Mobile App VEC authoring (for example, [sdkbetabus://com.adobe.sdkbetabus](sdkbetabus://com.adobe.sdkbetabus) ):
            <action android:name="android.intent.action.VIEW" /> 
            <category android:name="android.intent.category.DEFAULT" /> 
            <category android:name="android.intent.category.BROWSABLE" /> 
                android:scheme="sdkbetabus" /> 
  5. Go to your mobile project and insert the following lines at the end of Application::onCreate override :
    public class SDKTest extends MultiDexApplication { 
        public void onCreate() { 
            /* Put Your App's implementation */ 
            try { 
                TargetVEC.registerExtension(); //Single line code to initialize TargetVEC
            } catch (InvalidInitException e) { 
    /* Rest of Application test goes here ... */
  6. If your build is not working, review the example projects provided below that should build out-of-the-box and review changes in the following locations:
    1. Application::OnCreate override
    2. AndroidManifest.XML
    3. build.gradle of the Android application

Set Up Target Views on your mobile app

The Adobe Mobile SDK exposes a new method for developers to trigger whenever a new View is rendered. As a developer, you must ensure that the views are named uniquely, and the targetView call is on the UI main thread. In this section, we will first demonstrate how to insert these calls with two different demonstration applications and discuss general guidelines on how to properly insert the Target View API calls for any Android app.
If the targetView function is not triggered, the VEC extension tries to identify View from the Android activity. For applications that do not have dynamic views, this can be an optional step.
A Target View can be triggered with a function call. Any targeting parameters can be optionally provided with the view.
public class TargetVEC { 
    * Marks a view hierarchy for editing in Mobile App VEC.  Call must insert when the view hierarchy 
    * is memory and committed to being shown, but not yet shown on the screen. 
    * @param viewName the unique Target View Name 
   public static void targetView(String viewName); 
   * Trigger Target view 
   * Triggering a Target view may cause Target offers to be applied on the current container component. 
   * Note that Target offers are applied from local Target cache, so flicker should be negligible. 
   * @param viewName Mandatory Target View name, which must be unique at app level 
   * @param parameters Parameters to be included in the next Target call 
    public static void targetView(String viewName, TargetParameters parameters); 

Our first example project is a mock-up of simple bus schedule application. To set up this application for use in the Mobile App VEC:
  1. In Android Studio, open the project with the build.gradle file in the package subdirectory BusBooking .
  2. In the DemoApplication::OnCreate method, add TargetVEC.registerExtension() to register the Target VEC extension, along with other extensions.
  3. Build and run the application.
  4. To enter the Mobile App VEC authoring mode, use the sdkbetabus://com.adobe.sdkbetabus as its URL scheme, and open the generated deep link on the device (see directions below).
From this simple bus-booking application, we use all the automatically generated Target Views associated with the activity life cycle. Furthermore, we demonstrate the flexibility of the API by calling the Target View API on a custom view element that is dynamically added when a hidden button is clicked (the offer image on the screen). This new Target View is implemented by inserting an API call in the code at . When the hidden button is clicked, a new Target View event called "SURPRISE_VIEW" is fired, allowing the marketer to more precisely target change on the application experience.
Targeted Dynamic View Insertion:
import android.os.Bundle; 
import android.os.Handler; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.LinearLayout; 
import android.widget.Toast; 
 * This activity class is responsible to show offer details 
public class OfferDetailsActivity extends AppCompatActivity { 
    protected void onCreate(Bundle savedInstanceState) { 
        final Handler mainHandler = new Handler(getApplicationContext().getMainLooper()); 
        final View surpriseView = getLayoutInflater().inflate(R.layout.suprise_layout, 
                (ViewGroup) findViewById(, false); 
        final View imagePresentView = this.findViewById(; 
        final LinearLayout currentLayout = this.findViewById(; 
        imagePresentView.setOnClickListener(new View.OnClickListener() { 
            public void onClick(View v) { 
                Toast.makeText(getApplicationContext(),"Surprise!", Toast.LENGTH_SHORT).show(); 
       Runnable() { 
                    public void run() { 
                // One-shot.  Remove clicker afterwards. 
    private void setUpToolBar() { 
        Toolbar toolbar = findViewById(; 
        toolbar.setTitle("Buy 1 Get 1"); 
        toolbar.setNavigationOnClickListener(new View.OnClickListener() { 
            public void onClick(View v) { 
    protected void onPause() { 
    protected void onResume() { 

Setting Up profile parameters and other global parameters

We now support setting global parameters that will be passed in each and every API call, as well as passing mbox/view parameters to corresponding views.
Parameters include:
  • mbox/view parameters
  • profile parameters
  • Product parameters
  • Order parameters
Global parameter support:
Map<String, String> mboxParams = new HashMap<>();  //Mbox or view params 
mboxParams.put("mboxparam1", "mboxvalue1"); 
Map<String, String> profileParams = new HashMap<>();  //Profile params 
profileParams.put("profilekey1", "profilevalue1"); 
TargetVEC.setGlobalRequestParameters(new TargetParameters.Builder() 
        .product(new TargetProduct("1234", "furniture")) 
        .order(new TargetOrder("12343", 123.45, Arrays.asList("100", "200"))) 

Passing parameters for next view trigger:
We have provided some automatic views that are created by default, such as " AUTO_<activity|fragment name> " for each activity and fragment present in your app. If you want to pass these parameters, you can call the following API:
Map<String, String> mboxParams = new HashMap<>();  //Mbox or view params 
mboxParams.put("viewKey1", "viewparam1"); 
Map<String, String> profileParams = new HashMap<>();  //Profile params 
profileParams.put("profilekeyforview1", "profilevalueforview1"); 
TargetVEC.setRequestParameters(new TargetParameters.Builder() 
        .product(new TargetProduct("1234", "furniture")) 
        .order(new TargetOrder("12343", 123.45, Arrays.asList("100", "200"))) 

Passing parameters to a specific view:
We have seen the API trigger Views via TargetVEC.targetView("view_name") . You can also pass parameters that are specific to the particular view, as shown below:
Map<String, String> profileParams = new HashMap<>(); 
profileParams.put("surprisekey1", "surprisevalue1");  //ProfileParams 
        new TargetParameters.Builder() 
                .product(new TargetProduct("3354", "kitchen")) 

Calling the Prefetch API explicitly

There might be certain scenarios when you might want to call the prefetch API again to refresh the offers stored in cache. The following APIs are exposed, which are described as:
  • prefetchOffers
     * Prefetch Target offers. 
     * Note that calling this will pre-hide the current layout, until Target offers are prefetched 
     * and applied to currently visible Target views, possibly causing flicker, thus it's recommended 
     * to call this method inside the containing component's onCreate() lifecycle method 
    public static void prefetchOffers();
  • prefetchOffersBackground
     * Prefetch Target offers in the background. 
     * Note, that in contrast to prefetchOffers(), calling this method will NOT pre-hide 
     * the current layout, instead prefetched Target offers will be only be cached and will subsequently 
     * be applied as Target Views are being triggered. 
    public static void prefetchOffersBackground();

Tutorial: Implement the Experience Cloud in Mobile Android Applications

After completing this tutorial you will be able to:
  • Create a mobile Launch property
  • Install a Launch property in an Android app
  • Implement the following Adobe Experience Cloud solutions:
    • Experience Cloud ID Service
    • Adobe Target
    • Adobe Analytics
    • Adobe Audience Manager
  • Publish changes in Launch through development, staging, and production environments