Attempt to tie subprocess lifetime to the android activity.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4320 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-06-08 00:51:34 +00:00
parent ca28b5ca82
commit 0e8867dd6e
2 changed files with 15 additions and 6 deletions

View File

@ -494,7 +494,7 @@ out/%.apk: out/apk/%.unsigned.apk
apk: out/TildeFriends-debug.apk
.PHONY: apk
apkgo: out/TildeFriends-debug.apk
apkgo: out/TildeFriends-release.apk
@adb install $<
@adb shell am start com.unprompted.tildefriends/.MainActivity
.PHONY: apkgo

View File

@ -38,6 +38,7 @@ import java.util.zip.ZipInputStream;
public class MainActivity extends Activity {
WebView web_view;
String base_url;
Process process;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -122,15 +123,11 @@ public class MainActivity extends Activity {
builder.directory(getFilesDir());
builder.inheritIO();
try {
builder.start();
process = builder.start();
} catch (java.io.IOException e) {
Log.w("tildefriends", "IOException starting process: " + e.toString());
}
try {
Thread.sleep(1000);
} catch (java.lang.InterruptedException e) {
}
web_view.getSettings().setJavaScriptEnabled(true);
web_view.getSettings().setDatabaseEnabled(true);
web_view.getSettings().setDomStorageEnabled(true);
@ -188,6 +185,18 @@ public class MainActivity extends Activity {
});
}
@Override
protected void onDestroy()
{
if (process != null) {
Log.w("tildefriends", "Killing process.");
process.destroyForcibly();
Log.w("tildefriends", "Process killed.");
process = null;
}
super.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState)
{