### Initialize Adiscope SDK and Get Ad Instances (Java) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Initializes the Adiscope SDK using media credentials and retrieves instances for different ad types (Offerwall, Rewarded Video, Interstitial) upon successful initialization. Requires the Android Activity context, media ID, and media secret. It also allows setting a unique user ID for reward tracking. ```java import com.nps.adiscope.AdiscopeSdk; import com.nps.adiscope.listener.AdiscopeInitializeListener; import com.nps.adiscope.offerwall.OfferwallAd; import com.nps.adiscope.reward.RewardedVideoAd; import com.nps.adiscope.interstitial.InterstitialAd; public class MainActivity extends Activity { private OfferwallAd mOfferwallAd; private RewardedVideoAd mRewardedVideoAd; private InterstitialAd mInterstitialAd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize with media ID and secret AdiscopeSdk.initialize(this, "your_media_id", "your_media_secret", new AdiscopeInitializeListener() { @Override public void onInitialized(boolean isSuccess) { if (isSuccess) { Log.d("Adiscope", "SDK initialized successfully"); // Get ad instances after successful initialization mOfferwallAd = AdiscopeSdk.getOfferwallAdInstance(MainActivity.this); mRewardedVideoAd = AdiscopeSdk.getRewardedVideoAdInstance(MainActivity.this); mInterstitialAd = AdiscopeSdk.getInterstitialAdInstance(MainActivity.this); // Set user ID for reward tracking AdiscopeSdk.setUserId("unique_user_id_12345"); } else { Log.e("Adiscope", "SDK initialization failed"); } } }); } } ``` -------------------------------- ### Load and Show Rewarded Video Ad Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Handles the lifecycle of a rewarded video ad, including setup, loading, displaying, and managing callbacks for ad events such as loading success/failure, opening, closing, and reward granting. Requires Adiscope SDK initialization and a valid unit ID. ```java import com.nps.adiscope.reward.RewardedVideoAd; import com.nps.adiscope.reward.RewardedVideoAdListener; import com.nps.adiscope.reward.RewardItem; public class RewardedVideoActivity extends Activity implements RewardedVideoAdListener { private RewardedVideoAd mRewardedVideoAd; private static final String RV_UNIT_ID = "your_rv_unit"; private void setupRewardedVideo() { if (AdiscopeSdk.isInitialize()) { mRewardedVideoAd = AdiscopeSdk.getRewardedVideoAdInstance(this); mRewardedVideoAd.setRewardedVideoAdListener(this); } } private void loadRewardedVideo() { if (mRewardedVideoAd != null) { mRewardedVideoAd.load(RV_UNIT_ID); // Show loading indicator while ad loads showProgressBar(); } } private void showRewardedVideo() { if (mRewardedVideoAd != null && mRewardedVideoAd.isLoaded(RV_UNIT_ID)) { boolean shown = mRewardedVideoAd.show(); if (!shown) { Log.w("Adiscope", "Show already in progress"); } } else { Log.w("Adiscope", "Ad not loaded yet"); } } @Override public void onRewardedVideoAdLoaded(String unitId) { Log.d("Adiscope", "Rewarded video loaded: " + unitId); hideProgressBar(); showRewardedVideo(); } @Override public void onRewardedVideoAdFailedToLoad(String unitId, AdiscopeError error) { Log.e("Adiscope", "Load failed: " + error.getDescription()); hideProgressBar(); } @Override public void onRewardedVideoAdOpened(String unitId) { Log.d("Adiscope", "Rewarded video opened: " + unitId); } @Override public void onRewardedVideoAdClosed(String unitId) { Log.d("Adiscope", "Rewarded video closed: " + unitId); // Prepare for next show mRewardedVideoAd.load(RV_UNIT_ID); } @Override public void onRewarded(String unitId, RewardItem rewardItem) { String rewardType = rewardItem.getType(); int rewardAmount = rewardItem.getAmount(); Log.d("Adiscope", "Reward earned: " + rewardAmount + " " + rewardType); // Grant reward to user grantUserReward(rewardType, rewardAmount); } @Override public void onRewardedVideoAdFailedToShow(String unitId, AdiscopeError error) { Log.e("Adiscope", "Show failed: " + error.getDescription()); } private void grantUserReward(String type, int amount) { // Implement reward logic // Note: Use Server-to-Server callback for anti-fraud protection } } ``` -------------------------------- ### AdiscopeSdk Ad Instance Retrieval Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Methods to get instances of various ad types. ```APIDOC ## AdiscopeSdk Ad Instance Retrieval ### Description Retrieves instances of different ad types that can be used for ad operations. ### Method GET ### Endpoint /adiscope/sdk/adinstance ### Parameters #### Query Parameters - **activity** (Activity) - Required - The current Android activity. - **unitId** (String) - Required for `getUnitStatus` - The ID of the ad unit. - **callback** (IUnitStatus) - Required for `getUnitStatus` - Callback for unit status. ### Request Example ```java OfferwallAd offerwallAd = AdiscopeSdk.getOfferwallAdInstance(this); RewardedVideoAd rewardedVideoAd = AdiscopeSdk.getRewardedVideoAdInstance(this); InterstitialAd interstitialAd = AdiscopeSdk.getInterstitialAdInstance(this); RewardedInterstitialAd rewardedInterstitialAd = AdiscopeSdk.getRewardedInterstitialAdInstance(this); AdEvent adEvent = AdiscopeSdk.getAdEventInstance(this); OptionSetter optionSetter = AdiscopeSdk.getOptionSetterInstance(this); AdiscopeSdk.getUnitStatus("unit123", unitStatusCallback); ``` ### Response #### Success Response (200) Returns an instance of the requested ad type or unit status. #### Response Example ```json { "adInstance": "OfferwallAd Object", "unitStatus": "Active" } ``` ``` -------------------------------- ### Get Ad Networks Version (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Retrieves the version information for the integrated ad networks. Returns the version as a string. ```java public static String getNetworksVersion() ``` -------------------------------- ### Get Adiscope SDK Version (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Retrieves the current version of the Adiscope SDK. Returns the version as a string. ```java public static String getSDKVersion() ``` -------------------------------- ### Get Ad Instance for Adiscope (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Retrieves instances for various ad types from the Adiscope SDK. Requires an Activity context. ```java public OfferwallAd getOfferwallAdInstance(Activity activity) public RewardedVideoAd getRewardedVideoAdInstance(Activity activity) public InterstitialAd getInterstitialAdInstance(Activity activity) public RewardedInterstitialAd getRewardedInterstitialAdInstance(Activity activity) public AdEvent getAdEventInstance(Activity activity) public OptionSetter getOptionSetterInstance(Activity activity) ``` -------------------------------- ### Configure AndroidManifest for Adiscope (XML) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt This XML snippet configures the AndroidManifest.xml file with the necessary Adiscope metadata and permissions. It includes meta-data tags for `adiscope_media_id` and `adiscope_media_secret`, which should be replaced with actual credentials. It also shows an example of adding the AdMob App ID if the AdMob adapter is used. ```xml ``` -------------------------------- ### Get Ad Unit Status (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Retrieves the status of a specific ad unit. Requires the unit ID and a callback interface to handle the result. ```java public static void getUnitStatus(String unitId, IUnitStatus callback) ``` -------------------------------- ### Navigate to Offerwall Detail Page Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Demonstrates how to navigate to a specific offerwall sponsorship item detail page using either a sponsorship item ID or a direct URL. Requires an OfferwallAd instance and valid parameters. ```java public class OfferwallDetailActivity extends Activity { private OfferwallAd mOfferwallAd; // Method 1: Using sponsorship item ID private void showOfferwallDetailById() { String unitId = "your_offerwall_unit"; String[] excludeTypes = new String[]{}; int sponsorshipItemId = 12345; boolean shown = mOfferwallAd.showDetail( this, unitId, excludeTypes, sponsorshipItemId ); if (shown) { Log.d("Adiscope", "Showing detail for item: " + sponsorshipItemId); } } // Method 2: Using direct URL private void showOfferwallDetailByUrl() { String detailUrl = "https://your-subdomain.adiscope.com/..."; boolean shown = mOfferwallAd.showDetail(this, detailUrl); if (shown) { Log.d("Adiscope", "Showing detail from URL"); } } } ``` -------------------------------- ### Configure Gradle Dependencies for Adiscope (Groovy) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt This Groovy script configures the Gradle build files for an Android project to include Adiscope repositories and dependencies. It specifies repository URLs for Adiscope and various ad network adapters (AdMob, MAX, Chartboost, Pangle, Vungle) and defines necessary SDK dependencies in the app/build.gradle file. It also includes placeholder values for media ID and secret. ```groovy // settings.gradle - Add Adiscope repository dependencyResolutionManagement { repositories { google() mavenCentral() maven { url "https://repository.adiscope.com/repository/adiscope/" } // For MAX adapter maven { url "https://s3.amazonaws.com/smaato-sdk-releases/" } maven { url "https://artifactory.bidmachine.io/bidmachine" } // For Pangle adapter maven { url "https://artifact.bytedance.com/repository/pangle" } // For Chartboost adapter maven { url 'https://cboost.jfrog.io/artifactory/chartboost-ads/' } } } // app/build.gradle - Configure SDK dependencies android { defaultConfig { manifestPlaceholders = [ adiscope_media_id : "your_media_id", adiscope_media_secret: "your_media_secret", adiscope_sub_domain : "" // Optional for offerwall detail ] minSdkVersion 23 compileSdkVersion 35 } } dependencies { // Core Adiscope SDK (required) implementation 'com.nps.adiscope:adiscopeCore:5.0.0' implementation 'com.nps.adiscope:adiscopeAndroid:1.2.2' // Bidding adapters implementation 'com.nps.adiscope:adapter.admob:24.4.0.1' implementation 'com.nps.adiscope:adapter.max:13.3.1.3' // Waterfall adapters implementation 'com.nps.adiscope:adapter.chartboost:9.8.3.1' implementation 'com.nps.adiscope:adapter.pangle:7.7.0.2.0' implementation 'com.nps.adiscope:adapter.vungle:7.5.0.1' } ``` -------------------------------- ### Configure Adiscope SDK Options (Java) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt This Java code configures various Adiscope SDK options, including enabling the CloudFront proxy for improved performance, setting child-directed treatment for COPPA compliance, and managing ad volume. It uses the OptionSetter class obtained from AdiscopeSdk.getOptionSetterInstance(). ```java import com.nps.adiscope.option.OptionSetter; public class AdConfigManager { private void configureSdkOptions() { OptionSetter optionSetter = AdiscopeSdk.getOptionSetterInstance(this); // Enable CloudFront proxy for better performance in NA/EU optionSetter.setUseCloudFrontProxy(true); // Set child-directed treatment (for COPPA compliance) // "YES" = child or unknown, "NO" = not a child optionSetter.setChildYN("NO"); // Mute ad audio (not recommended - reduces revenue) optionSetter.setVolumeOff(false); Log.d("Adiscope", "SDK options configured"); } // Update child setting based on user age private void updateChildDirectedSetting(int userAge) { OptionSetter optionSetter = AdiscopeSdk.getOptionSetterInstance(this); if (userAge < 13) { optionSetter.setChildYN("YES"); Log.d("Adiscope", "Child-directed mode enabled"); } else { optionSetter.setChildYN("NO"); Log.d("Adiscope", "Child-directed mode disabled"); } } } ``` -------------------------------- ### Load and Show Interstitial Ads with Adiscope SDK Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Demonstrates how to load and show interstitial ads using the Adiscope SDK's load-show pair pattern. It handles ad loading, display, and callbacks for ad events like load success, failure, opening, and closing. The listener also includes logic to reload the ad after it's closed. Requires Adiscope SDK initialization. ```java import com.nps.adiscope.interstitial.InterstitialAd; import com.nps.adiscope.interstitial.InterstitialAdListener; public class InterstitialActivity extends Activity implements InterstitialAdListener { private InterstitialAd mInterstitialAd; private static final String INTERSTITIAL_UNIT_ID = "your_interstitial_unit"; private void setupInterstitial() { if (AdiscopeSdk.isInitialize()) { mInterstitialAd = AdiscopeSdk.getInterstitialAdInstance(this); mInterstitialAd.setInterstitialAdListener(this); } } private void loadInterstitial() { if (mInterstitialAd != null) { mInterstitialAd.load(INTERSTITIAL_UNIT_ID); } } private void showInterstitialIfReady() { if (mInterstitialAd != null && mInterstitialAd.isLoaded(INTERSTITIAL_UNIT_ID)) { boolean shown = mInterstitialAd.show(); if (!shown) { Log.w("Adiscope", "Interstitial show already in progress"); } } else { Log.w("Adiscope", "Interstitial not loaded"); } } @Override public void onInterstitialAdLoaded() { Log.d("Adiscope", "Interstitial loaded"); showInterstitialIfReady(); } @Override public void onInterstitialAdFailedToLoad(AdiscopeError error) { Log.e("Adiscope", "Interstitial load failed: " + error.getDescription()); } @Override public void onInterstitialAdOpened(String unitId) { Log.d("Adiscope", "Interstitial opened: " + unitId); } @Override public void onInterstitialAdClosed(String unitId) { Log.d("Adiscope", "Interstitial closed: " + unitId); // Reload for next display mInterstitialAd.load(INTERSTITIAL_UNIT_ID); } @Override public void onInterstitialAdFailedToShow(String unitId, AdiscopeError error) { Log.e("Adiscope", "Interstitial show failed: " + error.getDescription()); } } ``` -------------------------------- ### AdiscopeSdk General Methods Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Methods for checking initialization status, setting user ID, and retrieving SDK information. ```APIDOC ## AdiscopeSdk General Methods ### Description Provides utility methods for the Adiscope SDK. ### Method GET / POST ### Endpoint /adiscope/sdk ### Parameters #### Query Parameters - **userId** (String) - Required for `setUserId` - The unique identifier for the user. - **param** (String) - Required for `setRewardedCheckParam` - Parameter for rewarded ad checks. ### Request Example ```java boolean initialized = AdiscopeSdk.isInitialize(); AdiscopeSdk.setUserId("user123"); AdiscopeSdk.setRewardedCheckParam("rewardParam"); String sdkVersion = AdiscopeSdk.getSDKVersion(); String networksVersion = AdiscopeSdk.getNetworksVersion(); ``` ### Response #### Success Response (200) Returns status or version information. #### Response Example ```json { "isInitialize": true, "sdkVersion": "1.2.3", "networksVersion": "4.5.6" } ``` ``` -------------------------------- ### OptionSetter Configuration Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Methods for configuring SDK options. ```APIDOC ## OptionSetter Configuration ### Description Allows setting various configuration options for the Adiscope SDK. ### Method POST ### Endpoint /adiscope/optionsetter ### Parameters #### Query Parameters - **useCloudFrontProxy** (boolean) - Optional - Enables or disables CloudFront proxy. - **childYN** (String) - Optional - Sets child mode. - **volumeOff** (boolean) - Optional - Mutes audio for ads. ### Request Example ```java OptionSetter optionSetter = AdiscopeSdk.getOptionSetterInstance(this); optionSetter.setUseCloudFrontProxy(true); optionSetter.setChildYN("Y"); // Note: This might be redundant if set during initialization optionSetter.setVolumeOff(true); ``` ### Response #### Success Response (200) Indicates that the option has been set successfully. #### Response Example ```json { "status": "option_set" } ``` ``` -------------------------------- ### AdiscopeSdk Initialization Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Methods for initializing the Adiscope SDK with different configurations. ```APIDOC ## AdiscopeSdk Initialization ### Description Initializes the Adiscope SDK. This is a required step before using any other SDK functionalities. ### Method POST ### Endpoint /adiscope/sdk/initialize ### Parameters #### Query Parameters - **activity** (Activity) - Required - The current Android activity. - **listener** (AdiscopeInitializeListener) - Required - Callback listener for initialization status. - **callbackTag** (String) - Optional - A tag for callback identification. - **childYN** (String) - Optional - Specifies child mode. - **mediaId** (String) - Deprecated - Your media ID. - **mediaSecret** (String) - Deprecated - Your media secret. ### Request Example ```java AdiscopeSdk.initialize(this, listener); AdiscopeSdk.initialize(this, listener, "myTag"); AdiscopeSdk.initialize(this, listener, "myTag", "Y"); // Deprecated methods: AdiscopeSdk.initialize(this, "mediaId", "mediaSecret", listener); AdiscopeSdk.initialize(this, "mediaId", "mediaSecret", "myTag", listener); AdiscopeSdk.initialize(this, "mediaId", "mediaSecret", "myTag", "Y", listener); ``` ### Response #### Success Response (200) Indicates successful initialization. #### Response Example ```json { "status": "initialized" } ``` ``` -------------------------------- ### Show Offerwall Ads with Exclusions (Java) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Displays offerwall ads to the user and allows for optional exclusion of specific ad types, such as 'CPS' (Cost Per Sale). This functionality requires the Adiscope SDK to be initialized and an OfferwallAd instance to be set up with a listener. It returns a boolean indicating if the ad show process was initiated. ```java import com.nps.adiscope.offerwall.OfferwallAd; import com.nps.adiscope.offerwall.OfferwallAdListener; import com.nps.adiscope.AdiscopeError; public class OfferwallActivity extends Activity implements OfferwallAdListener { private OfferwallAd mOfferwallAd; private static final String OFFERWALL_UNIT_ID = "your_offerwall_unit"; private void setupOfferwall() { if (AdiscopeSdk.isInitialize()) { mOfferwallAd = AdiscopeSdk.getOfferwallAdInstance(this); mOfferwallAd.setOfferwallAdListener(this); } } private void showOfferwall() { if (mOfferwallAd != null) { // Exclude CPS ads (optional) String[] excludeAdTypes = new String[]{"CPS"}; boolean showStarted = mOfferwallAd.show(this, OFFERWALL_UNIT_ID, excludeAdTypes); if (showStarted) { Log.d("Adiscope", "Offerwall show initiated"); } else { Log.w("Adiscope", "Offerwall show already in progress"); } } } @Override public void onOfferwallAdOpened(String unitId) { Log.d("Adiscope", "Offerwall opened: " + unitId); } @Override public void onOfferwallAdFailedToShow(String unitId, AdiscopeError error) { Log.e("Adiscope", "Offerwall failed: " + error.getDescription()); } @Override public void onOfferwallAdClosed(String unitId) { Log.d("Adiscope", "Offerwall closed: " + unitId); } } ``` -------------------------------- ### Initialize Adiscope SDK (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Initializes the Adiscope SDK with various parameter options. Requires an Activity context and an AdiscopeInitializeListener. Overloads allow for specifying callback tags and child status. ```java public class AdiscopeSdk { public static void initialize(Activity activity, AdiscopeInitializeListener listener) public static void initialize(Activity activity, AdiscopeInitializeListener listener, String callbackTag) public static void initialize(Activity activity, AdiscopeInitializeListener listener, String callbackTag, String childYN) @Deprecated public static void initialize(Activity activity, String mediaId, String mediaSecret, AdiscopeInitializeListener listener) @Deprecated public static void initialize(Activity activity, String mediaId, String mediaSecret, String callbackTag, AdiscopeInitializeListener listener) @Deprecated public static void initialize(Activity activity, String mediaId, String mediaSecret, String callbackTag, String childYN, AdiscopeInitializeListener listener) // ... other methods } public interface AdiscopeInitializeListener { void onInitialized(boolean isSuccess) } ``` -------------------------------- ### Configure Server-to-Server Reward Verification with Java Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Shows how to set up server-side reward verification parameters for Adiscope using Java. It creates a JSON object with user-specific data, base64 encodes it, and sets it using `AdiscopeSdk.setRewardedCheckParam()`. Includes error handling for JSON creation and encoding, with a character limit check for the encoded parameter. ```java public class RewardCallbackManager { // Set custom parameters for reward callback public void setupRewardTracking(String userId, String sessionId, String level) { try { // Create JSON with custom data JSONObject customData = new JSONObject(); customData.put("user_id", userId); customData.put("session_id", sessionId); customData.put("level", level); // Base64 encode (UTF-8) - must be under 1000 chars String jsonString = customData.toString(); String encodedParam = Base64.encodeToString( jsonString.getBytes("UTF-8"), Base64.NO_WRAP ); if (encodedParam.length() <= 1000) { AdiscopeSdk.setRewardedCheckParam(encodedParam); Log.d("Adiscope", "Reward tracking parameters set"); } else { Log.e("Adiscope", "Custom param exceeds 1000 chars"); } } catch (Exception e) { Log.e("Adiscope", "Failed to set reward param", e); } } } ``` -------------------------------- ### Preload and Show Rewarded Interstitial Ads with Adiscope SDK Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Demonstrates preloading rewarded interstitial ad units and showing them with a skip confirmation dialog. This method allows for efficient ad delivery by pre-fetching ads. It handles callbacks for ad opening, closing, skipping, and successful reward. The SDK automatically reloads ads after closure or failure. ```java import com.nps.adiscope.rewardedinterstitial.RewardedInterstitialAd; import com.nps.adiscope.rewardedinterstitial.RewardedInterstitialAdShowListener; public class RewardedInterstitialActivity extends Activity implements RewardedInterstitialAdShowListener { private RewardedInterstitialAd mRewardedInterstitialAd; private String[] RI_UNITS = {"ri_unit_1", "ri_unit_2", "ri_unit_3"}; private void setupRewardedInterstitial() { if (AdiscopeSdk.isInitialize()) { mRewardedInterstitialAd = AdiscopeSdk.getRewardedInterstitialAdInstance(this); mRewardedInterstitialAd.setRewardedInterstitialAdListener(this); // Preload specific units after initialization mRewardedInterstitialAd.preloadUnit(RI_UNITS); // OR preload all active units // mRewardedInterstitialAd.preloadAll(); } } private void showRewardedInterstitial(String unitId) { if (mRewardedInterstitialAd != null) { // Shows confirmation dialog, then ad if user doesn't skip mRewardedInterstitialAd.show(unitId); } } @Override public void onRewardedInterstitialAdSkipped(String unitId) { Log.d("Adiscope", "User skipped confirmation: " + unitId); } @Override public void onRewardedInterstitialAdOpened(String unitId) { Log.d("Adiscope", "Rewarded interstitial opened: " + unitId); } @Override public void onRewardedInterstitialAdClosed(String unitId) { Log.d("Adiscope", "Rewarded interstitial closed: " + unitId); // Auto-reloads internally after close } @Override public void onRewardedInterstitialAdRewarded(String unitId, RewardItem rewardItem) { Log.d("Adiscope", "Reward: " + rewardItem.getAmount() + " " + rewardItem.getType()); grantReward(rewardItem); } @Override public void onRewardedInterstitialAdFailedToShow(String unitId, AdiscopeError error) { Log.e("Adiscope", "Show failed: " + error.getDescription()); // Auto-reloads internally after failure } } ``` -------------------------------- ### Handle Adiscope Errors with Java Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Demonstrates how to handle errors returned by the Adiscope SDK using Java. It checks for null errors, extracts error codes and descriptions, and logs them. A switch statement categorizes common error codes for specific user feedback or logging actions. ```java import com.nps.adiscope.AdiscopeError; public class AdErrorHandler { public void handleAdError(AdiscopeError error) { if (error == null) { return; } int errorCode = error.getCode(); String errorDescription = error.getDescription(); String traceId = error.getXb3TraceId(); Log.e("Adiscope", String.format( "Ad Error - Code: %d, Description: %s, TraceID: %s", errorCode, errorDescription, traceId )); switch (errorCode) { case 0: // Success/No error break; case 1000: // Network error showUserMessage("Network connection issue. Please try again."); break; case 2000: // No ad available showUserMessage("No ads available at the moment."); break; case 3000: // Ad already shown Log.w("Adiscope", "Ad show already in progress"); break; default: // Unknown error showUserMessage("An error occurred: " + errorDescription); break; } } private void showUserMessage(String message) { // Display toast or dialog to user } } ``` -------------------------------- ### Check Ad Unit Status with Adiscope SDK (Java) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt This Java code snippet shows how to check if an ad unit is active and monetizing using the Adiscope SDK. It requires the Adiscope SDK to be initialized and provides a callback to handle the unit status, differentiating between live and active states to determine ad loading or alternative content display. ```java import com.nps.adiscope.core.IUnitStatus; import com.nps.adiscope.core.UnitStatus; public class AdStatusManager { public void checkUnitStatus(String unitId) { if (!AdiscopeSdk.isInitialize()) { Log.w("Adiscope", "SDK not initialized"); return; } AdiscopeSdk.getUnitStatus(unitId, new IUnitStatus() { @Override public void onResult(AdiscopeError error, UnitStatus unitStatus) { if (error != null) { Log.e("Adiscope", "Status check failed: " + error.getDescription()); return; } boolean isLive = unitStatus.isLive(); boolean isActive = unitStatus.isActive(); Log.d("Adiscope", "Unit " + unitId + " - Live: " + isLive + ", Active: " + isActive); if (isLive && isActive) { // Unit is ready to show ads loadAd(unitId); } else { // Unit is disabled or not monetizing showAlternativeContent(); } } }); } } ``` -------------------------------- ### Check Adiscope SDK Initialization Status (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Checks if the Adiscope SDK has been successfully initialized. Returns a boolean value. ```java public static boolean isInitialize() ``` -------------------------------- ### Set or Update User ID for Reward Tracking (Java) Source: https://context7.com/adiscope/adiscope-android-sample/llms.txt Sets a unique user identifier for reward tracking and attribution purposes. This function should be called after the Adiscope SDK has been successfully initialized. It also supports updating the user ID dynamically, for instance, when a user switches accounts in the application. ```java // Set user ID after SDK initialization AdiscopeSdk.setUserId("user_abc123"); // Update user ID on account switch (multi-account apps) public void onUserAccountChanged(String newUserId) { if (AdiscopeSdk.isInitialize()) { AdiscopeSdk.setUserId(newUserId); Log.d("Adiscope", "User ID updated to: " + newUserId); } } ``` -------------------------------- ### Set User ID for Adiscope SDK (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Sets a unique user identifier for the Adiscope SDK. This is typically used for user-specific ad targeting or analytics. ```java public static void setUserId(String userId) ``` -------------------------------- ### Set Rewarded Check Parameter for Adiscope (Java) Source: https://github.com/adiscope/adiscope-android-sample/blob/master/docs/api_documentation.md Sets a parameter used for checking rewarded ad status. This method is specific to rewarded ad configurations. ```java public static void setRewardedCheckParam(String param) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.