Skip to content

Latest commit

 

History

History
66 lines (51 loc) · 2.35 KB

File metadata and controls

66 lines (51 loc) · 2.35 KB

CloudX Android SDK - Take-Home Interview

Overview

This repository contains an Android ads SDK and demo app with basic interstitial ad functionality.

Project Structure

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

Getting Started

  1. Open the project in Android Studio
  2. Run ./gradlew build to build the project
  3. Run the app module on an emulator or device

Demo App

The demo app has four buttons:

  1. Initialize SDK - Initializes the CloudX SDK
  2. Create Interstitial - Creates an interstitial ad instance
  3. Load Interstitial - Loads ad content from the server
  4. Show Interstitial - Displays the fullscreen ad

How It Works

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:

  1. MockAdServer starts a local HTTP server
  2. The SDK fetches configuration from the /init endpoint
  3. The server returns a base URL for subsequent ad requests

When loading an ad:

  1. The SDK requests ad content from /ads?adUnitId=...
  2. The server returns ad payload (title, body, CTA) and tracking URLs
  3. The ad content is stored until show() is called

When showing an ad:

  1. InterstitialActivity launches and displays the ad content
  2. Impression is tracked via the /impression endpoint
  3. Clicks are tracked via the /click endpoint

The mock server includes simulated network latency and occasional failures to mimic real-world conditions.