# SafeSMS: On-Device Threat Detection with Gemma 4 E4B, no internet required

> Source: <https://dev.to/parulmalhotraiitk/safesms-on-device-threat-detection-with-gemma-4-e4b-no-internet-required-24p3>
> Published: 2026-05-23 07:16:45+00:00

This is a submission for the Gemma 4 Challenge: Build with Gemma 4
SafeSMS is a privacy-first Android application designed to protect users from the rising threat of SMS-based scams, phishing, and spam.
Traditional SMS scanners and spam filters often send your private text messages to the cloud for analysis, creating severe privacy concerns. SafeSMS takes a completely different approach: it brings the intelligence directly to the device.
By running a powerful, on-device AI model, it performs real-time threat detection locally on your phone. It monitors incoming messages, categorizes them (SAFE, SUSPICIOUS, or SCAM), provides a confidence score, and explains why a message is dangerous.
The app features a sleek dark-mode UI built with Jetpack Compose, including:
Incoming SMS:
Your bank account will be blocked. Click immediately: http://bit.ly/xyz
SafeSMS Output:
[https://youtu.be/2NhvyiARX1c]
To enable real-time, completely private SMS analysis, SafeSMS uses Gemma 4 via LiteRT for on-device inference.
I selected the E4B model because it perfectly fits mobile and edge environments:
Absolute Privacy
All SMS data stays on-device. No cloud calls, no data leakage.
Zero Latency & Offline Capability
Messages are analyzed instantly without any network dependency.
Resource Efficiency
The lightweight model runs efficiently inside a background Android service with minimal battery impact.
Strong Reasoning in a Small Model
Despite its compact size, the model effectively detects:
The model is prompted using a structured classification + reasoning format, enabling it to return:
This ensures both accuracy and transparency in predictions.
SafeSMS follows a fully on-device architecture, ensuring privacy, speed, and reliability.
Incoming SMS
Protection Service
SafeSMS Model Controller
On-Device AI Inference
Result Handling
User Interface (Jetpack Compose)
SafeSMS demonstrates how powerful AI models like Gemma 4 can run entirely on-device, enabling real-world applications that are fast, private, and reliable.
It’s a step toward a future where user data never has to leave their device to stay safe.
