Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding stopWithTask tag and onTaskRemoved to the service #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
```
<service android:name="com.voximplant.foregroundservice.VIForegroundService"> </service>
<service android:name="com.voximplant.foregroundservice.VIForegroundService"
android:stopWithTask="true"/>
```

- React Native <= 0.59

Expand All @@ -37,29 +39,31 @@ See [the Android official documentation](https://developer.android.com/guide/com
```
2. Add VIForegroundService as a service to the application's `AndroidManifest.xml`:
```
<service android:name="com.voximplant.foregroundservice.VIForegroundService"> </service>
<service android:name="com.voximplant.foregroundservice.VIForegroundService"
android:stopWithTask="true"/>
```

### Manual installation (Android only, React Native <= 0.59)
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
- 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`:
```
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
```
5. Add VIForegroundService as a service to the application's `AndroidManifest.xml`:
```
<service android:name="com.voximplant.foregroundservice.VIForegroundService"> </service>
<service android:name="com.voximplant.foregroundservice.VIForegroundService"
android:stopWithTask="true"/>
```

## Demo project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}