Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit 5b11fcc

Browse files
author
devfd
committed
Android instructions
1 parent 642fe70 commit 5b11fcc

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
Spin worker threads and run CPU intensive tasks in the background. Bonus point on Android you can keep a worker alive even when a user quit the application :fireworks:
44

55
## Features
6-
- JS workers run on both iOS and Android
7-
- access all native modules from the workers (network, geolocation, async storage ...)
8-
- write your Android Services in JS :tada:
6+
- JS workers for iOS and Android
7+
- access to native modules (network, geolocation, storage ...)
8+
- Android Services in JS :tada:
99

1010
## Warning
1111
This plugin is still in beta and some features are missing. Current restrictions include:
@@ -23,10 +23,56 @@ npm install react-native-workers --save
2323

2424
### iOS
2525

26-
1. Open your project in XCode, right click on Libraries and click Add Files to "Your Project Name". Look under node_modules/react-native-workers/ios and add `Workers.xcodeproj`.
27-
2. Add `libWorkers.a` to `Build Phases -> Link Binary With Libraries.
26+
1. Open your project in XCode, right click on Libraries and click Add Files to "Your Project Name". Look under node_modules/react-native-workers/ios and add `Workers.xcodeproj`
27+
2. Add `libWorkers.a` to `Build Phases -> Link Binary With Libraries`
2828

29-
## API
29+
### Android
30+
31+
in `android/settings.gradle`
32+
33+
```
34+
include ':app', ':react-native-workers'
35+
project(':react-native-workers').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-workers/android')
36+
```
37+
38+
in `android/app/build.gradle` add:
39+
40+
```
41+
dependencies {
42+
...
43+
compile project(':react-native-workers')
44+
}
45+
```
46+
47+
and finally, in your `MainActivity.java` add:
48+
49+
```java
50+
51+
import co.apptailor.Worker.WorkerPackage; // <--- This!
52+
53+
public class MainActivity extends ReactActivity {
54+
55+
@Override
56+
protected String getMainComponentName() {
57+
return "MyApp";
58+
}
59+
60+
@Override
61+
protected boolean getUseDeveloperSupport() {
62+
return BuildConfig.DEBUG;
63+
}
64+
65+
@Override
66+
protected List<ReactPackage> getPackages() {
67+
return Arrays.<ReactPackage>asList(
68+
new MainReactPackage(),
69+
new WorkerPackage() // <---- and This!
70+
);
71+
}
72+
}
73+
```
74+
75+
## JS API
3076

3177
From your application:
3278
```js

0 commit comments

Comments
 (0)