Skip to content
Back to skills

Add Android Foreground Service

ASecurity

Add an Android foreground service (for music, fitness tracking, downloads). Requires FGSTYPE declaration in Android 14+. Use when the user says 'foreground service android', 'background tracking android', 'persistent notification android'.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 4, 2026
developmentgobashreact

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 2 files and shows the line behind each finding

Scanned October 4, 2026

npx -y skills add khadinakbarlabs/expo-mobile-app-builder --skill add-android-foreground-service --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Android Foreground Service?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Add Android Foreground Service
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/khadinakbarlabs-add-android-foreground-service/badge)](https://www.skillsdirectory.com/skills/khadinakbarlabs-add-android-foreground-service)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: "add-android-foreground-service"
description: "Add an Android foreground service (for music, fitness tracking, downloads). Requires FGSTYPE declaration in Android 14+. Use when the user says 'foreground service android', 'background tracking android', 'persistent notification android'."
---

# Add Android Foreground Service

Run code that survives app background. Requires user-visible persistent notification.

## Android 14+ requirement

Must declare `foregroundServiceType` in `AndroidManifest.xml`:
- `location` — GPS tracking
- `mediaPlayback` — audio playback
- `phoneCall` — VoIP
- `connectedDevice` — Bluetooth, Watch
- `camera` — recording
- `mediaProjection` — screen recording
- `microphone` — voice recording
- `health` — fitness/health
- `dataSync` — file sync
- `shortService` — <3 min total

Each requires Play Console justification + video at submission!

## RN+Expo approach

```bash
pnpm add @notifee/react-native
```

Notifee wraps Android's NotificationCompat + foreground service. Best community option.

```tsx
import notifee from '@notifee/react-native';

await notifee.displayNotification({
  title: 'Tracking workout',
  body: 'Running for 23 min',
  android: {
    channelId: 'workout',
    asForegroundService: true,
    ongoing: true,
    smallIcon: 'ic_notification',
  },
});

// To stop:
await notifee.stopForegroundService();
```

## Service type declaration (config plugin needed)

Inject into `AndroidManifest.xml` via expo-build-properties:
```json
{
  "expo-build-properties": {
    "android": {
      "manifestPlaceholders": {
        "foregroundServiceType": "location"
      }
    }
  }
}
```

Or use a custom config plugin.

## When users will see the persistent notif

ALWAYS while service runs. User can tap to open app, can swipe-dismiss only on Android 14+ if you allow.

## Play Console justification

Submit a 30-sec video showing:
1. What the service does
2. Why the persistent notif is needed
3. How users start/stop it

Common rejections:
- "App doesn't need a foreground service for this" → use WorkManager instead
- "Type 'dataSync' used for analytics" → wrong type
- "User can't stop the service"

## When NOT to use

- Periodic background work → use WorkManager (no notif required)
- Push notifications → FCM
- Brief tasks (<10 sec) → use coroutine in app

## Pair with
- `add-expo-notifications-fcm` for push (different concern)
- `add-onesignal-push` for marketing push

Files in this skill

  • SKILL.md2.4 KB
  • agents/openai.yaml221 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…