An AI-Powered Personal Safety Application Using RunAnywhere SDK
Discreet emergency assistance through intelligent threat assessment and automated contact alerting - completely on-device for maximum privacy.
Guardian AI is a personal safety application that uses on-device AI to:
- Assess Emergency Threats: AI generates protocol questions to determine severity
- Smart Contact Alerting: Automatically decides who to contact based on threat level
- Progressive Escalation: Monitors situations and escalates if needed
- Complete Privacy: All AI processing happens locally using RunAnywhere SDK
User triggers alarm (discreet button)
↓
AI generates safety question ("Can you safely move to a public area?")
↓
30-second timer for response
↓
┌────────────────────────────┐
│ Can user answer quickly? │
├────────────────┬───────────┤
│ YES │ NO │
↓ ↓
MEDIUM threat HIGH threat
SMS to family Calls + location + emergency services
- Protocol Questions: AI generates contextual safety questions
- Threat Assessment: Analyzes response time and ability to answer
- Smart Escalation: Automatically escalates based on time and responses
- Action Selection: AI decides who to contact and how (SMS, call, emergency services)
- 100% On-Device AI: Uses RunAnywhere SDK with llama.cpp
- No Cloud Processing: All decisions made locally
- No Data Collection: Emergency contacts stored locally only
- Location Privacy: GPS only shared when emergency active
- 5 Threat Levels: UNKNOWN → LOW → MEDIUM → HIGH → CRITICAL
- Automated Alerts: SMS, calls, missed calls, emergency services
- Location Sharing: Automatic GPS coordinates in emergency messages
- False Alarm Protection: Easy cancellation with notifications
- Discreet Activation: Single button trigger (future: shake, voice, volume buttons)
- Real-Time Countdown: Visual timer for protocol questions
- Status Monitoring: Color-coded threat level indicators
- Contact Management: Priority-based emergency contacts
app/src/main/java/com/runanywhere/startup_hackathon20/
│
├── MyApplication.kt # SDK initialization, model registration
│
├── SafetyModels.kt # Data models (contacts, threats, sessions)
├── SafetyAIEngine.kt # AI decision engine (RunAnywhere SDK)
├── SafetyViewModel.kt # Complete business logic
│
├── MainActivity.kt # Safety UI implementation
│
├── [TO ADD] CommunicationManager.kt # SMS, calls, emergency dialer
├── [TO ADD] LocationManager.kt # GPS tracking, location services
├── [TO ADD] ContactsScreen.kt # Manage emergency contacts
└── [TO ADD] SettingsScreen.kt # Model management, permissions
-
SafetyModels.kt (103 lines)
EmergencyContact,ThreatLevel,ProtocolQuestionEmergencySession,AlertRecord,EmergencyAction
-
SafetyAIEngine.kt (389 lines)
- Protocol question generation
- Threat level assessment
- AI decision making with RunAnywhere SDK
- Emergency message generation
- Escalation logic
-
SafetyViewModel.kt (599 lines)
- Complete emergency workflow
- Protocol question presentation
- Response handling (YES/NO/timeout)
- Action execution orchestration
- Escalation monitoring
- False alarm cancellation
See BUILD_SAFETY_APP.md for step-by-step guide.
Priority 1 (Week 1):
- Communication layer (SMS, calls)
- Location services integration
- Safety UI implementation
- Runtime permissions
Priority 2 (Week 2):
- Contacts management screen
- Settings screen
- Alert history
Priority 3 (Week 3+):
- Foreground service
- Advanced features (shake-to-activate, disguise mode, voice commands)
- Android Studio (latest stable)
- JDK 17+
- Android device/emulator (API 24+, 2GB+ RAM)
git clone <your-repo-url>
cd Hackss
# Open in Android StudioAdd to app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />Add to app/build.gradle.kts:
dependencies {
// ... existing dependencies ...
implementation("com.google.android.gms:play-services-location:21.0.1")
}See BUILD_SAFETY_APP.md for complete UI code (just copy/paste!)
- Load AI model (tap "Load AI Model" button)
- Trigger emergency (tap red button)
- Answer protocol question
- Check LogCat for AI decisions
Expected Logs:
SafetyViewModel: Emergency session started
SafetyAIEngine: AI generated question: "Can you confirm you are safe right now?"
SafetyViewModel: Threat level updated: MEDIUM
SafetyViewModel: SMS to Mom: I've activated my safety app...
| Document | Description |
|---|---|
| BUILD_SAFETY_APP.md | Quick start guide with ready-to-use UI code |
| SAFETY_APP_IMPLEMENTATION_GUIDE.md | Complete implementation guide (750+ lines) |
| RUNANYWHERE_SDK_COMPLETE_GUIDE.md | Full RunAnywhere SDK documentation |
Trigger alarm → Question appears → Answer YES within 5 seconds
Expected: MEDIUM threat → SMS to primary family contact
Trigger alarm → Question appears → Answer YES after 15 seconds
Expected: MEDIUM threat → Missed calls to top 3 contacts
Trigger alarm → Question appears → Answer NO or timeout
Expected: HIGH threat → Calls + location SMS to top contacts
Trigger alarm → No response → 5 minutes pass
Expected: CRITICAL threat → Emergency services + all contacts
Trigger alarm → Cancel button → Confirm
Expected: All contacted people receive "False alarm. I'm safe now."
All AI decisions processed locally (RunAnywhere SDK with llama.cpp)
No cloud API calls for threat assessment or decision making
Emergency contacts stored locally (SharedPreferences/Room)
Location only shared during active emergency
No training data collection - AI model is frozen
- PIN/biometric protection for alarm cancellation
- Disguised app mode (looks like calculator)
- Auto-wipe data after failed PIN attempts
- Encrypted emergency session history
- Kotlin - Modern Android development
- Jetpack Compose - Declarative UI
- Coroutines + Flow - Async operations and reactive state
- ViewModel + StateFlow - MVVM architecture
- Core SDK (4.0 MB) - Model management, analytics, event system
- LlamaCpp Module (2.1 MB) - 7 ARM64 optimized inference variants
- Models: Qwen 2.5 0.5B (374 MB) for emergency response
- SmsManager - Emergency text messages
- TelephonyManager - Phone calls
- FusedLocationProvider - GPS tracking
- WorkManager - Background monitoring
- NotificationManager - Foreground service
The AI engine uses on-device LLM to make intelligent decisions:
You are a personal safety AI assistant...
Context: A person has triggered an emergency alarm.
Generate ONE simple yes/no question that can quickly assess if they
are in immediate danger. The question should be something they can
answer quickly if they're safe, but cannot answer if actively threatened.
Question:
"Can you safely move to a public area right now?"
when {
!victimResponded -> ThreatLevel.HIGH
responseTimeSeconds > 30 -> ThreatLevel.HIGH
responseTimeSeconds < 5 -> ThreatLevel.MEDIUM
else -> ThreatLevel.MEDIUM
}LOW threat:
→ SMS to primary family contact
MEDIUM threat:
→ Missed calls to top 3 contacts
HIGH threat:
→ Calls + location SMS to top 2 contacts
CRITICAL threat:
→ Emergency services + all priority contacts
- Personal Safety: Walking alone at night
- Domestic Violence: Discreet emergency alert
- Medical Emergency: Quick family notification
- Child Safety: Students with safety concerns
- Elderly Care: Fall detection + alert
- Travel Safety: Solo travelers in unfamiliar areas
- Check-in System: Auto-alert if check-in missed
- Geofencing: Alert if entering/leaving safe zones
- Scheduled Monitoring: AI checks in during vulnerable times
- Group Safety: Multiple users with shared contacts
- AI decision engine
- Business logic and workflow
- Safety UI implementation
- SMS and call integration
- Location services
- Basic testing
- Contacts management UI
- Settings and model management
- Runtime permissions flow
- Alert history
- Notification system
- Foreground service
- Shake-to-activate
- Voice command activation
- Disguised mode
- PIN protection
- Geofencing
- Check-in system
- Evidence recording
- Multi-language support
- Accessibility features
This is a safety-critical application. Contributions should be:
- Well-tested - Emergency features must be reliable
- Privacy-focused - Never compromise on-device processing
- Accessible - Consider users in high-stress situations
- Documented - Clear code and decision reasoning
This project uses the RunAnywhere SDK which follows its own license terms.
See RunAnywhere SDK Repository for details.
- Implementation Questions: See BUILD_SAFETY_APP.md
- SDK Issues: Check RUNANYWHERE_SDK_COMPLETE_GUIDE.md
- Architecture Questions: Review SAFETY_APP_IMPLEMENTATION_GUIDE.md
This app is designed to assist in emergency situations but should not be relied upon as the sole means of protection. Always call emergency services (911, 112, etc.) directly if in immediate danger.
- RunAnywhere SDK - On-device AI inference
- llama.cpp - Optimized LLM inference engine
- HuggingFace - Model hosting (Qwen 2.5)
- Android Open Source Project - Platform and APIs
Built with privacy, safety, and speed in mind using on-device AI.
Stay Safe. Stay Protected. Stay Private.