More starting diagnostics on android.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4515 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
ed307e6b3b
commit
05a7e941cf
@ -1,7 +1,5 @@
|
|||||||
package com.unprompted.tildefriends;
|
package com.unprompted.tildefriends;
|
||||||
|
|
||||||
import android.os.StrictMode;
|
|
||||||
import android.os.strictmode.Violation;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@ -9,6 +7,8 @@ import android.content.Intent;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
|
import android.os.StrictMode;
|
||||||
|
import android.os.strictmode.Violation;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -24,9 +24,9 @@ import android.widget.TextView;
|
|||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
import java.lang.Process;
|
import java.lang.Process;
|
||||||
import java.lang.Thread;
|
import java.lang.Thread;
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
@ -35,6 +35,7 @@ import java.nio.file.StandardWatchEventKinds;
|
|||||||
import java.nio.file.WatchEvent;
|
import java.nio.file.WatchEvent;
|
||||||
import java.nio.file.WatchKey;
|
import java.nio.file.WatchKey;
|
||||||
import java.nio.file.WatchService;
|
import java.nio.file.WatchService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String port_file_path = getFilesDir().toString() + "/port.txt";
|
String port_file_path = getFilesDir().toString() + "/port.txt";
|
||||||
|
new File(port_file_path).delete();
|
||||||
base_url = "http://127.0.0.1:12345/";
|
base_url = "http://127.0.0.1:12345/";
|
||||||
|
|
||||||
MainActivity activity = this;
|
MainActivity activity = this;
|
||||||
@ -80,10 +82,19 @@ public class MainActivity extends Activity {
|
|||||||
StandardWatchEventKinds.ENTRY_CREATE,
|
StandardWatchEventKinds.ENTRY_CREATE,
|
||||||
StandardWatchEventKinds.ENTRY_MODIFY);
|
StandardWatchEventKinds.ENTRY_MODIFY);
|
||||||
while (true) {
|
while (true) {
|
||||||
WatchKey key = watcher.take();
|
WatchKey key = watcher.poll(100, TimeUnit.MILLISECONDS);
|
||||||
|
boolean attempt_it = true;
|
||||||
|
if (key != null)
|
||||||
|
{
|
||||||
|
attempt_it = false;
|
||||||
for (WatchEvent event : key.pollEvents()) {
|
for (WatchEvent event : key.pollEvents()) {
|
||||||
if (event.context().toString().equals("port.txt")) {
|
if (event.context().toString().equals("port.txt")) {
|
||||||
Log.w("tildefriends", "Observed file write: " + event.context().toString());
|
Log.w("tildefriends", "Observed file write: " + event.context().toString());
|
||||||
|
attempt_it = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attempt_it) {
|
||||||
int port = read_port(port_file_path);
|
int port = read_port(port_file_path);
|
||||||
if (port >= 0) {
|
if (port >= 0) {
|
||||||
base_url = "http://127.0.0.1:" + String.valueOf(port) + "/";
|
base_url = "http://127.0.0.1:" + String.valueOf(port) + "/";
|
||||||
@ -98,7 +109,6 @@ public class MainActivity extends Activity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!key.reset()) {
|
if (!key.reset()) {
|
||||||
Log.w("tildefriends", "watcher is no longer valid");
|
Log.w("tildefriends", "watcher is no longer valid");
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user