summaryrefslogtreecommitdiff
path: root/src/pw/cloudef/rpg
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2022-02-17 04:35:24 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2022-02-17 04:35:24 +0900
commitbc493cc00746e0ba6d17b77c122cbf33ed16e8e5 (patch)
tree2cc72992a25cfc8700e51bc3036968d8a987b2e9 /src/pw/cloudef/rpg
parentf19c280566277f341901d86fe3f383268c5d1706 (diff)
launcher: better activity handling and cleanup
Diffstat (limited to 'src/pw/cloudef/rpg')
-rw-r--r--src/pw/cloudef/rpg/Launcher.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/pw/cloudef/rpg/Launcher.java b/src/pw/cloudef/rpg/Launcher.java
index 626ac14..ab2e9b2 100644
--- a/src/pw/cloudef/rpg/Launcher.java
+++ b/src/pw/cloudef/rpg/Launcher.java
@@ -74,6 +74,14 @@ public class Launcher extends Activity {
return null;
}
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ try { Os.remove(zipPath()); } catch (Exception e) {}
+ try { Os.remove(baseDir() + "/game.zip"); } catch (Exception e) {}
+ try { Os.remove(baseDir() + "/rtp"); } catch (Exception e) {}
+ finishAndRemoveTask();
+ }
+
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
@@ -82,6 +90,7 @@ public class Launcher extends Activity {
OutputStream output = new FileOutputStream(file);
byte[] buf = new byte[8 * 1024];
for (int read = 0; (read = input.read(buf)) != -1;) output.write(buf, 0, read);
+ output.close(); input.close();
Class activity = getActivityForZip(file);
if (activity == null) throw new Exception("Can't handle this game");
new File(baseDir()).mkdirs();
@@ -92,13 +101,14 @@ public class Launcher extends Activity {
Os.symlink(rtpDir(), baseDir() + "/rtp");
Intent intent = new Intent(this, activity);
intent.putExtra("id", gameId());
- startActivity(intent);
+ startActivityForResult(intent, 1);
finish();
} catch (Exception e) {
Log.d("pw.cloudef.rpg", e.toString());
try { Os.remove(zipPath()); } catch (Exception e2) {}
try { Os.remove(baseDir() + "/game.zip"); } catch (Exception e2) {}
+ try { Os.remove(baseDir() + "/rtp"); } catch (Exception e2) {}
+ finishAndRemoveTask();
}
- finishAndRemoveTask();
}
}