A complete Android application that displays real-time internet speed (download & upload) in the STATUS BAR using a FOREGROUND SERVICE.
- ✅ Real-time Speed Monitoring - Shows download and upload speeds
- ✅ Status Bar Display - Persistent notification with speed info
- ✅ Foreground Service - Runs continuously in background
- ✅ Battery Efficient - Uses Android TrafficStats API
- ✅ Material Design UI - Clean and modern interface
- ✅ Android 13+ Support - Handles runtime permissions
- ✅ Auto-format Speed - Automatically switches between B/s, KB/s, and MB/s
- ✅ Boot Receiver - Optional auto-start on device boot
- Min SDK: 21 (Android 5.0 Lollipop)
- Target SDK: 34 (Android 14)
- Language: Kotlin
- Architecture: MVVM-ready structure
- Build System: Gradle 8.2
- Dependencies: AndroidX, Material Components
InternetSpeedMeter/
├── app/
│ ├── src/
│ │ └── main/
│ │ ├── java/com/speedmeter/app/
│ │ │ ├── MainActivity.kt # Main UI Activity
│ │ │ ├── SpeedService.kt # Foreground Service
│ │ │ └── BootReceiver.kt # Boot auto-start receiver
│ │ ├── res/
│ │ │ ├── drawable/
│ │ │ │ └── ic_speed.xml # App icon
│ │ │ ├── layout/
│ │ │ │ └── activity_main.xml # Main UI layout
│ │ │ └── values/
│ │ │ ├── strings.xml # String resources
│ │ │ ├── colors.xml # Color palette
│ │ │ └── themes.xml # App theme
│ │ └── AndroidManifest.xml # App manifest
│ ├── build.gradle # App-level build config
│ └── proguard-rules.pro # ProGuard rules
├── gradle/
│ └── wrapper/
│ └── gradle-wrapper.properties # Gradle wrapper config
├── build.gradle # Project-level build config
├── settings.gradle # Project settings
├── gradle.properties # Gradle properties
└── README.md # This file
- Android Studio Arctic Fox or newer
- JDK 8 or higher
- Android SDK with API 34 installed
-
Open in Android Studio
File → Open → Select "InternetSpeedMeter" folder -
Update SDK Path (if needed)
- Open
local.properties - Set your Android SDK path:
sdk.dir=C:\\Users\\YourUsername\\AppData\\Local\\Android\\Sdk
- Open
-
Sync Project
File → Sync Project with Gradle Files -
Build Project
Build → Make Project -
Run on Device
Run → Run 'app'
The app requires the following permissions:
INTERNET- Required for network accessACCESS_NETWORK_STATE- Check network connectivityFOREGROUND_SERVICE- Run foreground serviceFOREGROUND_SERVICE_DATA_SYNC- Android 14+ requirementPOST_NOTIFICATIONS- Android 13+ notification permissionRECEIVE_BOOT_COMPLETED- Auto-start on boot (optional)
The app uses Android's TrafficStats API to monitor network traffic:
// Get total bytes received/transmitted
val currentRxBytes = TrafficStats.getTotalRxBytes()
val currentTxBytes = TrafficStats.getTotalTxBytes()
// Calculate speed (bytes per second)
val downloadSpeed = (currentRxBytes - previousRxBytes) / timeDiff
val uploadSpeed = (currentTxBytes - previousTxBytes) / timeDiffThe service runs continuously and updates every second:
- Creates a persistent notification
- Updates notification with current speed
- Uses
START_STICKYto restart if killed - Low importance channel (no sound/vibration)
Speed format in notification:
↓ 850 KB/s ↑ 120 KB/s
Auto-formats based on speed:
- < 1 KB: Shows in B/s
- < 1 MB: Shows in KB/s
- ≥ 1 MB: Shows in MB/s (2 decimal places)
- Launch the app
- Grant notification permission (Android 13+)
- Tap "START SPEED METER"
- Check your status bar - Speed appears in notification
- Close the app - Service continues running
- Tap "STOP SPEED METER" to stop monitoring
In BootReceiver.kt, uncomment the code in onReceive():
val serviceIntent = Intent(it, SpeedService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
it.startForegroundService(serviceIntent)
} else {
it.startService(serviceIntent)
}In SpeedService.kt, modify:
private const val UPDATE_INTERVAL = 1000L // Change to 2000L for 2 secondsIn SpeedService.kt, update the createInitialNotification() method to change:
- Title
- Icon
- Priority
- Color
For best results, users should disable battery optimization:
- Settings → Apps → Internet Speed Meter
- Battery → Unrestricted
You can guide users programmatically:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val intent = Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)
startActivity(intent)
}- Check battery optimization settings
- Ensure notification channel is not blocked
- Verify app has notification permission
- Check if device has active internet connection
- VPN might interfere with TrafficStats
- Some devices don't support TrafficStats properly
- Manually grant notification permission in Settings
- Target SDK must be properly configured
- Memory Usage: ~20-30 MB
- Battery Impact: Minimal (~1-2% per hour)
- CPU Usage: Very low (updates only once per second)
- Network Impact: None (only reads system stats)
Edit res/values/colors.xml:
<color name="primary">#2196F3</color> <!-- Blue -->
<color name="secondary">#F44336</color> <!-- Red -->Replace res/drawable/ic_speed.xml with your custom icon.
Edit res/layout/activity_main.xml to customize the interface.
This project is provided as-is for educational and commercial use.
Feel free to improve this project:
- Add settings screen for customization
- Implement speed history graphs
- Add widget support
- Export speed logs
- Add themes (dark/light mode)
For issues or questions:
- Check logcat for errors
- Verify all permissions are granted
- Test on physical device (not emulator)
Before releasing to Play Store:
- Test on multiple devices (Android 5-14)
- Test with different network conditions
- Verify notification works correctly
- Test service survival (force stop, reboot)
- Check battery optimization behavior
- Add privacy policy (if collecting data)
- Create app screenshots
- Write store description
- Generate signed APK/AAB
- Initial release
- Real-time speed monitoring
- Foreground service implementation
- Status bar notification
- Material Design UI
Made with ❤️ for Android Developers