diff --git a/README.md b/README.md index 5898411..c2b5ac4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ See [the Android official documentation](https://developer.android.com/guide/com ``` 2. Add VIForegroundService as a service to the application's `AndroidManifest.xml`: ``` - + + ``` - React Native <= 0.59 @@ -37,7 +39,8 @@ See [the Android official documentation](https://developer.android.com/guide/com ``` 2. Add VIForegroundService as a service to the application's `AndroidManifest.xml`: ``` - + ``` ### Manual installation (Android only, React Native <= 0.59) @@ -45,21 +48,22 @@ See [the Android official documentation](https://developer.android.com/guide/com - Add `import com.voximplant.foregroundservice.VIForegroundServicePackage;` to the imports at the top of the file - Add `new VIForegroundServicePackage()` to the list returned by the `getPackages()` method 2. Append the following lines to `android/settings.gradle`: - ``` - include ':@voximplant_react-native-foreground-service' + ``` + include ':@voximplant_react-native-foreground-service' project(':@voximplant_react-native-foreground-service').projectDir = new File(rootProject.projectDir, '../node_modules/@voximplant/react-native-foreground-service/android') - ``` + ``` 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: - ``` + ``` implementation project(':@voximplant_react-native-foreground-service') - ``` + ``` 4. Add the FOREGROUND_SERVICE permission to the application's `AndroidManifest.xml`: ``` ``` 5. Add VIForegroundService as a service to the application's `AndroidManifest.xml`: ``` - + ``` ## Demo project diff --git a/android/src/main/java/com/voximplant/foregroundservice/VIForegroundService.java b/android/src/main/java/com/voximplant/foregroundservice/VIForegroundService.java index facc65a..8df8290 100644 --- a/android/src/main/java/com/voximplant/foregroundservice/VIForegroundService.java +++ b/android/src/main/java/com/voximplant/foregroundservice/VIForegroundService.java @@ -40,4 +40,11 @@ public int onStartCommand(Intent intent, int flags, int startId) { return START_NOT_STICKY; } + + @Override + public void onTaskRemoved(Intent rootIntent) { + super.onTaskRemoved(rootIntent); + stopSelf(); + } + } \ No newline at end of file