android docs update

This commit is contained in:
Joseph Henry
2016-08-25 14:24:13 -07:00
parent 0180cbe5cd
commit 95f74b18f6
2 changed files with 54 additions and 54 deletions

View File

@@ -16,37 +16,37 @@ If you want to skip the following steps and just take a look at the project, go
- Start the service - Start the service
``` ```
String nwid = "8056c2e21c000001"; String nwid = "8056c2e21c000001";
// Set up service // Set up service
final ZTSDK zt = new ZTSDK(); final ZTSDK zt = new ZTSDK();
final String homeDir = getApplicationContext().getFilesDir() + "/zerotier"; final String homeDir = getApplicationContext().getFilesDir() + "/zerotier";
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {
// Calls to JNI code // Calls to JNI code
zt.start_service(homeDir); zt.start_service(homeDir);
} }
}).start(); }).start();
while(!zt.running()) { } while(!zt.running()) { }
``` ```
- Join network and start doing network stuff! - Join network and start doing network stuff!
``` ```
zt.join_network(nwid); zt.join_network(nwid);
int sock = zt.socket(zt.AF_INET, zt.SOCK_STREAM, 0); int sock = zt.socket(zt.AF_INET, zt.SOCK_STREAM, 0);
int err = zt.connect(sock, "10.9.9.203", 8080, nwid); int err = zt.connect(sock, "10.9.9.203", 8080, nwid);
// zt.recvfrom(), zt.write(), etc... // zt.recvfrom(), zt.write(), etc...
``` ```
**Step 2: App permissions** **Step 2: App permissions**
- In order for your application to write the auth keys and network files to the internal storage you'll need to set a few permissions in your `AndroidManifest.xml` file at the same scope level as `<application>`: - In order for your application to write the auth keys and network files to the internal storage you'll need to set a few permissions in your `AndroidManifest.xml` file at the same scope level as `<application>`:
``` ```
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
``` ```
**Step 3: Set NDK/SDK paths** **Step 3: Set NDK/SDK paths**
- Specify your SDK/NDK path in `android_jni_lib/proj/local.properties`. For example: - Specify your SDK/NDK path in `android_jni_lib/proj/local.properties`. For example:

View File

@@ -16,37 +16,37 @@ If you want to skip the following steps and just take a look at the project, go
- Start the service - Start the service
``` ```
String nwid = "8056c2e21c000001"; String nwid = "8056c2e21c000001";
// Set up service // Set up service
final ZTSDK zt = new ZTSDK(); final ZTSDK zt = new ZTSDK();
final String homeDir = getApplicationContext().getFilesDir() + "/zerotier"; final String homeDir = getApplicationContext().getFilesDir() + "/zerotier";
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {
// Calls to JNI code // Calls to JNI code
zt.start_service(homeDir); zt.start_service(homeDir);
} }
}).start(); }).start();
while(!zt.running()) { } while(!zt.running()) { }
``` ```
- Join network and start doing network stuff! - Join network and start doing network stuff!
``` ```
zt.join_network(nwid); zt.join_network(nwid);
int sock = zt.socket(zt.AF_INET, zt.SOCK_STREAM, 0); int sock = zt.socket(zt.AF_INET, zt.SOCK_STREAM, 0);
int err = zt.connect(sock, "10.9.9.203", 8080, nwid); int err = zt.connect(sock, "10.9.9.203", 8080, nwid);
// zt.recvfrom(), zt.write(), etc... // zt.recvfrom(), zt.write(), etc...
``` ```
**Step 2: App permissions** **Step 2: App permissions**
- In order for your application to write the auth keys and network files to the internal storage you'll need to set a few permissions in your `AndroidManifest.xml` file at the same scope level as `<application>`: - In order for your application to write the auth keys and network files to the internal storage you'll need to set a few permissions in your `AndroidManifest.xml` file at the same scope level as `<application>`:
``` ```
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
``` ```
**Step 3: Set NDK/SDK paths** **Step 3: Set NDK/SDK paths**
- Specify your SDK/NDK path in `android_jni_lib/proj/local.properties`. For example: - Specify your SDK/NDK path in `android_jni_lib/proj/local.properties`. For example: