Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add interface and enum in this code. #28

Open
palashmandokhot opened this issue Mar 6, 2017 · 1 comment
Open

how to add interface and enum in this code. #28

palashmandokhot opened this issue Mar 6, 2017 · 1 comment

Comments

@palashmandokhot
Copy link

import com.apptracker.android.listener.AppModuleListener;
import com.apptracker.android.track.AppTracker;
// Leadbolt SDK imports

public class MainActivity extends Activity {

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

    if(savedInstanceState == null) {
        // Initialize Leadbolt SDK with your api key
        AppTracker.startSession(getApplicationContext(),"YOUR_APP_API_KEY",AppTracker.ENABLE_AUTO_CACHE);
    }
    // cache Leadbolt Ad without showing it
    AppTracker.loadModuleToCache(getApplicationContext(),"inapp");
}

public void gameOver() {
    // call this when you want to display the Leadbolt Interstitial
    if(AppTracker.isAdReady("inapp")) {
            AppTracker.loadModule(getApplicationContext(),"inapp");
    }
}

}
AppTracker.setAgeRange("18-25");
// Allowed values for Age range are: "13-17", "18-25", "26-35", "36-45", "46+"

AppTracker.setGender("Female");
// Allowed values for Gender are: "Male", "Female"
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import com.apptracker.android.listener.AppModuleListener;
import com.apptracker.android.track.AppTracker;
// Leadbolt SDK imports

public class MainActivity extends Activity {

private AppModuleListener leadboltListener = new AppModuleListener() {
	@Override
	public void onModuleLoaded(String location) {
		// Add code here to pause game and/or all media including audio
	}
	@Override
	public void onModuleFailed(String location, String error, boolean isCache) {}
	@Override
	public void onModuleClosed(String location) {
		// Add code here to resume game and/or all media including audio
	}
	@Override
	public void onModuleClicked(String location) {}
	@Override
	public void onModuleCached(String location) {
		// Add code if not auto-recaching for when loadModuleModuleToCache is successful
	}
	@Override
	public void onMediaFinished(boolean viewCompleted) {
		if(viewCompleted) {
			Log.i("AppTracker", "User finished watching rewarded video");
		} else {
			Log.i("AppTracker", "User skipped watching rewarded video");
		}
	}
};
   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if(savedInstanceState == null) {
        // Initialize Leadbolt SDK with your api key
        AppTracker.setModuleListener(leadboltListener);
		AppTracker.startSession(getApplicationContext(),"YOUR_APP_API_KEY",AppTracker.ENABLE_AUTO_CACHE);
    }
    // cache Leadbolt Video Ad without showing it
    AppTracker.loadModuleToCache(getApplicationContext(),"video");
}

public void gameOver() {
    // call this when you want to display the Leadbolt Video
    if(AppTracker.isAdReady("video")) {
            AppTracker.loadModule(getApplicationContext(),"video");
    }      
}

}

1
2
3
4
5
AppTracker.setAgeRange("18-25");
// Allowed values for Age range are: "13-17", "18-25", "26-35", "36-45", "46+"

AppTracker.setGender("Female");
// Allowed values for Gender are: "Male", "Female"
private AppModuleListener leadboltListener = new AppModuleListener() {
@OverRide
public void onModuleLoaded(String location) {
Log.i("AppTracker", "Ad loaded successfully - "+location);
// Add code here to pause game and/or all media including audio
}
@OverRide
public void onModuleFailed(String location, String error, boolean isCache) {
if(isCache) {
Log.i("AppTracker", "Ad failed to cache - "+location);
} else {
Log.i("AppTracker", "Ad failed to display - "+location);
}
}
@OverRide
public void onModuleClosed(String location) {
Log.i("AppTracker", "Ad closed by user - "+location);
// Add code here to resume game and/or all media including audio
}
@OverRide
public void onModuleClicked(String location) {
Log.i("AppTracker", "Ad clicked by user - "+location);
}
@OverRide
public void onModuleCached(String location) {
Log.i("AppTracker", "Ad cached successfully - "+location);
// Add code if not auto-recaching for when loadModuleModuleToCache is successful
}
@OverRide
public void onMediaFinished(boolean viewCompleted) {
if(viewCompleted) {
Log.i("AppTracker", "User finished watching rewarded video");
} else {
Log.i("AppTracker", "User skipped watching rewarded video");
}
}
};

2
AppTracker.setModuleListener(leadboltListener);
AppTracker.startSession(getApplicationContext(),"YOUR_APP_API_KEY",AppTracker.ENABLE_AUTO_CACHE);

@ASHUTOSH2224
Copy link

import com.apptracker.android.listener.AppModuleListener;
import com.apptracker.android.track.AppTracker;

// Interface for AdType
public interface AdType {
String getLocation();
}

// Enum for Ad Locations
public enum AdLocation implements AdType {
INTERSTITIAL("inapp"),
VIDEO("video");

private final String location;

AdLocation(String location) {
this.location = location;
}

@OverRide
public String getLocation() {
return location;
}
}

// Leadbolt SDK integration
public class MainActivity extends Activity {

private final AppModuleListener leadboltListener = new AppModuleListener() {
// Implement methods for handling ad events (as before)
};

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

if (savedInstanceState == null) {
  AppTracker.setModuleListener(leadboltListener);
  AppTracker.startSession(getApplicationContext(), "YOUR_APP_API_KEY", AppTracker.ENABLE_AUTO_CACHE);

  // Cache Leadbolt ad based on AdType
  cacheAd(AdLocation.INTERSTITIAL);
}

}

public void gameOver() {
if (AppTracker.isAdReady(getSelectedAd().getLocation())) {
AppTracker.loadModule(getApplicationContext(), getSelectedAd().getLocation());
}
}

private AdType getSelectedAd() {
// Choose the appropriate AdType based on your logic (e.g., return AdLocation.VIDEO)
return AdLocation.INTERSTITIAL;
}

private void cacheAd(AdType adType) {
AppTracker.loadModuleToCache(getApplicationContext(), adType.getLocation());
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants