This repository contains an Android ads SDK and demo app with basic interstitial ad functionality.
android/
├── app/ # Demo application
│ └── src/main/java/io/cloudx/interview/
│ ├── InterviewApplication.kt
│ └── MainActivity.kt
│
└── sdk/ # CloudX SDK
└── src/main/java/io/cloudx/sdk/
├── CloudX.kt # SDK entry point
├── CloudXInterstitialAd.kt # Interstitial ad interface
├── CloudXInterstitialAdListener.kt
└── internal/
├── AdUtil.kt # HTTP client for ad operations
├── AdContent.kt # Ad data models
├── CloudXInterstitialAdImpl.kt
├── InterstitialActivity.kt # Fullscreen ad display
├── MockAdServer.kt # Simulated ad server
├── NetworkHelper.kt
├── SdkConfiguration.kt
└── SdkInitializer.kt
- Open the project in Android Studio
- Run
./gradlew buildto build the project - Run the
appmodule on an emulator or device
The demo app has four buttons:
- Initialize SDK - Initializes the CloudX SDK
- Create Interstitial - Creates an interstitial ad instance
- Load Interstitial - Loads ad content from the server
- Show Interstitial - Displays the fullscreen ad
The SDK uses a local MockWebServer to simulate a real ad server. This allows the project to run without external dependencies.
When the SDK initializes:
MockAdServerstarts a local HTTP server- The SDK fetches configuration from the
/initendpoint - The server returns a base URL for subsequent ad requests
When loading an ad:
- The SDK requests ad content from
/ads?adUnitId=... - The server returns ad payload (title, body, CTA) and tracking URLs
- The ad content is stored until
show()is called
When showing an ad:
InterstitialActivitylaunches and displays the ad content- Impression is tracked via the
/impressionendpoint - Clicks are tracked via the
/clickendpoint
The mock server includes simulated network latency and occasional failures to mimic real-world conditions.