forked from cory/tildefriends
		
	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:
		| @@ -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) | ||||
| 	{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user