adjust-icon

Android Adobe Extension example implementation

This page contains a full example implementation of the Adjust Android Extension for Adobe Experience SDK.

You can see the full example on GitHub.

MainApp.java
package com.adjust.examples;
import android.app.Application;
import android.net.Uri;
import android.util.Log;
import com.adjust.adobeextension.AdjustAdobeExtension;
import com.adjust.adobeextension.AdjustAdobeExtensionConfig;
import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustAttribution;
import com.adjust.sdk.OnAttributionChangedListener;
import com.adjust.sdk.OnDeferredDeeplinkResponseListener;
import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Extension;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import java.util.Arrays;
import java.util.List;
public class MainApp extends Application {
@Override
public
void onCreate() {
super.onCreate();
// set application object
MobileCore.setApplication(this);
// set log level
// internally translates to Adjust SDK logging
MobileCore.setLogLevel(LoggingMode.VERBOSE);
// configure Adjust Adobe Extension
configureAdjustAdobeExtension();
// register extensions
try {
List<Class<? extends Extension>> extensions = Arrays.asList(AdjustAdobeExtension.EXTENSION);
MobileCore.registerExtensions(extensions, new AdobeCallback<Object>() {
@Override
public void call(Object o) {
Log.d("example", "Adjust Adobe Extension SDK initialized");
}
});
} catch (Exception e) {
Log.e("example", "Exception while registering Extension: " + e.getMessage());
}
}
private void configureAdjustAdobeExtension() {
try {
MobileCore.configureWithAppID("89645c501ce0/540de252943f/launch-f8d889dd15b6-development");
AdjustAdobeExtensionConfig config =
new AdjustAdobeExtensionConfig(AdjustAdobeExtensionConfig.ENVIRONMENT_SANDBOX);
// Optional callbacks
// Set attribution delegate.
config.setOnAttributionChangedListener(new OnAttributionChangedListener() {
@Override
public void onAttributionChanged(AdjustAttribution attribution) {
Log.d("example", "Attribution callback called!");
Log.d("example", "Attribution: " + attribution.toString());
}
});
// Evaluate deferred deep link to be launched.
config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() {
@Override
public boolean launchReceivedDeeplink(Uri uri) {
Log.d("example", "Deferred deep link callback called!");
Log.d("example", "Deep link URL: " + uri);
return true;
}
});
// register the Adjust SDK extension
AdjustAdobeExtension.setConfiguration(config);
} catch (Exception e) {
}
// Add global callback parameters.
Adjust.addGlobalCallbackParameter("gc_foo", "gc_bar");
Adjust.addGlobalCallbackParameter("gc_key", "gc_value");
// Add global partner parameters.
Adjust.addGlobalPartnerParameter("gp_foo", "gp_bar");
Adjust.addGlobalPartnerParameter("gp_key", "gp_value");
}
}
MainActivity.java
package com.adjust.examples;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.adjust.adobeextension.AdjustAdobeExtension;
import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustDeeplink;
import com.adobe.marketing.mobile.MobileCore;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
@Override
protected
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
Uri data = intent.getData();
AdjustDeeplink adjustDeeplink = new AdjustDeeplink(data);
Adjust.processDeeplink(adjustDeeplink, getApplicationContext());
}
public void trackSimpleEvent(View view) {
String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;
Map<String, String> contextData= new HashMap<String, String>();
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "g3mfiw");
MobileCore.trackAction(action, contextData);
}
public void trackRevenueEvent(View view) {
String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;
Map<String, String> contextData= new HashMap<String, String>();
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "a4fd35");
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_REVENUE, "0.01");
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_CURRENCY, "EUR");
MobileCore.trackAction(action, contextData);
}
public void trackCallbackEvent(View view) {
String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;
Map<String, String> contextData= new HashMap<String, String>();
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "34vgg9");
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX + "key1", "value1");
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_CALLBACK_PARAM_PREFIX + "key2", "value2");
MobileCore.trackAction(action, contextData);
}
public void trackPartnerEvent(View view) {
String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_TRACK_EVENT;
Map<String, String> contextData= new HashMap<String, String>();
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_TOKEN, "w788qs");
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX + "key1", "value1");
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_EVENT_PARTNER_PARAM_PREFIX + "key2", "value2");
MobileCore.trackAction(action, contextData);
}
public void setPushToken(View view) {
String action = AdjustAdobeExtension.ADOBE_ADJUST_ACTION_SET_PUSH_TOKEN;
Map<String, String> contextData= new HashMap<String, String>();
contextData.put(AdjustAdobeExtension.ADOBE_ADJUST_PUSH_TOKEN, "your_push_token");
MobileCore.trackAction(action, contextData);
}
}