[android][expo-location][bare] How to change the foreground service icon ?
See original GitHub issueHi, I use expo-location in a bare React Native app :
"expo-constants": "9.0.0",
"expo-location": "8.1.0",
"expo-task-manager": "8.1.0",
"react": "16.11.0",
"react-native": "0.62.0",
When I start a foregroundTask via startLocationUpdatesAsync a default notification icon is displayed.
Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
accuracy: Location.Accuracy.BestForNavigation,
distanceInterval: 20, //meters
//ios
showsBackgroundLocationIndicator: true,
activityType: Location.ActivityType.AutomotiveNavigation,
pausesUpdatesAutomatically: true,
//android
timeInterval: 1000, //milliseconds
foregroundService: {
notificationTitle: 'Title',
notificationBody: 'body,
notificationColor: '#FF00FF',
},
});
I would like to know how I can change the foreground icon ?
As I can see in the LocationTaskService.java file, the icon comes from “getApplicationInfo().icon”.
How can I override this icon ?
I try to update my app.json file but with no success
{
"name": "MyApp",
"displayName": "My App",
"icon": "./src/assets/images/Icon-1024x1024.png",
"expo": {
"icon": "./src/assets/images/Icon-1024x1024.png",
"notification": {
"icon": "./src/assets/images/Icon-1024x1024.png"
}
}
}

Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:19 (6 by maintainers)
Top Results From Across the Web
How to change the status bar icon while service is running
The workaround is to just create a new notification with a new icon, so it'll replace the old one. EDIT: Here's a sample...
Read more >Foreground services - Android Developers
The service has opted out of the behavior change by passing FOREGROUND_SERVICE_IMMEDIATE into setForegroundServiceBehavior() when setting up the notification.
Read more >Foreground service icon appears in status bar on Android 8.1
Since roughly Android 4.2, the foreground service icon hasn't been visible in the status bar, but it has become visible again on Android...
Read more >How to Start a Foreground Service in Android (With ... - YouTube
In this video we will learn how to start a foreground service in Android, which runs independently from other app components (like ...
Read more >flutter_foreground_task | Flutter Package - Pub.dev
This plugin is used to implement a foreground service on the Android platform ... flutter_foreground_task 3.10.0 icon indicating copy to clipboard operation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@andkom 's answer helped me a lot and now the app uses the same icon for location as it does for notifications. I created a patch file that can be applied using patch-package
To apply the patch in your build, follow these steps:
Install
patch-packageCreate a new file
patches/expo-location+12.1.2.patchand copy-paste the following code.Update your
package.jsonto runpatch-packageafter each install:Run
npm installfollowed bynpm run android. The icon should be updated.I’m not sure if the team is already working on a different way of setting the default icon, but I can provide a pull request if that is desired.
Thanks, I will make a feature request.