Skip to content

Commit

Permalink
in which our hero adds Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Exner committed Feb 3, 2020
1 parent 091f3f7 commit 0479a1b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.adobe.marketing.mobile:analytics:1.+'
implementation 'com.adobe.marketing.mobile:target:1.+'
implementation 'com.adobe.marketing.mobile:userprofile:1.+'
implementation 'com.adobe.marketing.mobile:sdk-core:1.+'
}
implementation 'com.adobe.marketing.mobile:sdk-core:1.+'}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.content.Intent;
import android.os.Bundle;

import com.adobe.marketing.mobile.TargetPrefetch;
import com.adobe.marketing.mobile.Analytics;
import com.adobe.marketing.mobile.TargetRequest;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
Expand Down Expand Up @@ -33,7 +33,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

Expand All @@ -44,6 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
MobileCore.setLogLevel(LoggingMode.DEBUG);

try {
Analytics.registerExtension();
Target.registerExtension();
UserProfile.registerExtension();
Identity.registerExtension();
Expand All @@ -60,13 +63,23 @@ public void call(Object o) {
}

setContentView(R.layout.activity_main);

// create contextData map
Map<String,String> contextData = new HashMap<>();
// add language = en
contextData.put("language", "en");
MobileCore.trackState("Home", contextData);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
// track this into Analytics
MobileCore.trackAction("Targeting Button tapped", null);
// now over to Target
Snackbar.make(view, "Creating Target request...", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
TargetRequest targetRequest1 = new TargetRequest("w4dmobile-targeting1", null
Expand Down Expand Up @@ -138,4 +151,17 @@ public boolean onOptionsItemSelected(MenuItem item) {

return super.onOptionsItemSelected(item);
}

@Override
public void onResume() {
super.onResume();
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}

@Override
public void onPause() {
MobileCore.lifecyclePause();
super.onPause();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@

import android.os.Bundle;

import com.adobe.marketing.mobile.MobileCore;

import java.util.HashMap;
import java.util.Map;

public class SettingsActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
// create contextData map
Map<String,String> contextData = new HashMap<>();
// add language = en
contextData.put("language", "en");
MobileCore.trackState("Settings", contextData);
}

@Override
public void onResume() {
super.onResume();
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}

@Override
public void onPause() {
MobileCore.lifecyclePause();
super.onPause();
}

}

0 comments on commit 0479a1b

Please sign in to comment.