Implementing Adaptive Content Quality Based on 5G Speed in Mobile Applications
5G provides bandwidth previously unavailable in mobile networks. However, simply "enabling maximum quality on 5G" is the wrong approach. 5G speed is inconsistent: 5G NSA (Non-Standalone) often performs like LTE with minimal benefits in practice, while mmWave signal degrades around building corners. Adaptation should respond to real measured network parameters, not network type alone.
Measuring Real Throughput
NetworkCapabilities.getLinkDownstreamBandwidthKbps() on Android returns an estimated speed from the radio module—not the actual current throughput. It provides technology-based averages (LTE: ~20 Mbps, 5G Sub-6: ~100–400 Mbps), not current channel measurements.
For real throughput, use active probing or passive observation of actual HTTP responses. The most accurate approach: measure throughput from real transfers using exponential moving average:
// Update throughput estimate with each download
function updateThroughputEstimate(bytesLoaded: number, durationMs: number) {
const measuredKbps = (bytesLoaded * 8) / durationMs; // kbps per ms = Mbps
// EMA with alpha=0.3 — smooth but responsive to recent data
throughputEstimate = 0.7 * throughputEstimate + 0.3 * measuredKbps;
}
EMA (Exponentially Moving Average) smooths outliers. alpha=0.3 works well for moderately variable networks. For unstable networks (mmWave), use alpha=0.5.
Content Quality Levels
Standard video quality tiers:
| Level | Bitrate | Resolution | Minimum Throughput |
|---|---|---|---|
| Low | 400 kbps | 360p | 600 kbps |
| Medium | 1.5 Mbps | 720p | 2 Mbps |
| High | 4 Mbps | 1080p | 5 Mbps |
| Ultra | 15 Mbps | 4K | 20 Mbps |
For images: WebP with different quality tables (JPEG quality 40/60/80/95 or WebP equivalents), or different sizes (400px, 800px, 1600px, 3200px).
Hysteresis: Prevent Frequent Switching
Without hysteresis, the app will "flicker" between quality levels near threshold values. Rule: require 20–30% sustainable surplus to upgrade quality; only 10% drop below minimum to downgrade.
const UPGRADE_BUFFER = 1.3; // +30% margin to upgrade
const DOWNGRADE_THRESHOLD = 0.9; // -10% to downgrade
function selectQualityLevel(currentKbps: number, currentLevel: QualityLevel): QualityLevel {
const levels = [LOW, MEDIUM, HIGH, ULTRA];
const idx = levels.indexOf(currentLevel);
// Try upgrade
if (idx < levels.length - 1) {
const next = levels[idx + 1];
if (currentKbps >= next.minKbps * UPGRADE_BUFFER) return next;
}
// Try downgrade
if (idx > 0) {
if (currentKbps < currentLevel.minKbps * DOWNGRADE_THRESHOLD) return levels[idx - 1];
}
return currentLevel;
}
Additionally: don't switch more than once every 5–10 seconds. Debounce quality level changes.
iOS: Network Path Monitor
On iOS, use NWPathMonitor from Network.framework:
import Network
let monitor = NWPathMonitor()
monitor.pathUpdateHandler = { path in
if path.usesInterfaceType(.cellular) {
// Check 5G availability via path.status and isExpensive
let is5G = path.isConstrained == false // heuristic, no direct API
DispatchQueue.main.async {
self.updateQualityForPath(path)
}
}
}
monitor.start(queue: DispatchQueue.global(qos: .background))
iOS doesn't provide direct API to identify "this is 5G with these parameters." CTTelephonyNetworkInfo.currentRadioAccessTechnology returns technology type: CTRadioAccessTechnologyNRNSA (5G NSA) or CTRadioAccessTechnologyNR (5G SA). But type ≠ speed. Combine with active throughput measurement.
Preloading on High-Speed Transition
When 5G with high throughput is detected, initiate preload of next content before user requests it. In video apps: preload the next video in queue to 50–60% during idle. In image feeds: load ultra-resolution versions of visible elements and the next 3–5 items beyond viewport.
react-native-fast-image supports preloading via FastImage.preload([...]). On native iOS: URLSession with background configuration allows tasks to continue in background.
Estimate
Adaptive content quality with throughput measurement, hysteresis, and preload logic: 3–5 weeks for one platform. Cross-platform implementation (React Native with native modules): 4–7 weeks.







