From 932bfa3242f9cc10038116ec796b9a4a665c7da3 Mon Sep 17 00:00:00 2001 From: Greg Alexander Date: Wed, 17 Dec 2014 19:34:35 -0500 Subject: [PATCH] save the static pointer to the main Activity in SimpleSSHD because it'll be used by more than just SimpleSSHDService.. --- src/org/galexander/sshd/SimpleSSHD.java | 8 ++++---- src/org/galexander/sshd/SimpleSSHDService.java | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/org/galexander/sshd/SimpleSSHD.java b/src/org/galexander/sshd/SimpleSSHD.java index 93e5b5e..3547286 100644 --- a/src/org/galexander/sshd/SimpleSSHD.java +++ b/src/org/galexander/sshd/SimpleSSHD.java @@ -16,9 +16,9 @@ import android.net.Uri; public class SimpleSSHD extends Activity { private Button startstop_view; + public static SimpleSSHD curr = null; - public void onCreate(Bundle savedInstanceState) - { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Prefs.init(this); setContentView(R.layout.main); @@ -28,11 +28,11 @@ public class SimpleSSHD extends Activity public void onResume() { super.onResume(); update_startstop(); - SimpleSSHDService.activity = this; + curr = this; } public void onPause() { - SimpleSSHDService.activity = null; + curr = null; super.onPause(); } diff --git a/src/org/galexander/sshd/SimpleSSHDService.java b/src/org/galexander/sshd/SimpleSSHDService.java index c14a717..a4a816b 100644 --- a/src/org/galexander/sshd/SimpleSSHDService.java +++ b/src/org/galexander/sshd/SimpleSSHDService.java @@ -10,7 +10,6 @@ import java.io.FileReader; public class SimpleSSHDService extends Service { public static int sshd_pid = 0; - public static SimpleSSHD activity = null; public void onCreate() { super.onCreate(); @@ -84,10 +83,10 @@ public class SimpleSSHDService extends Service { } private static void update_activity() { - if (activity != null) { - activity.runOnUiThread(new Runnable() { + if (SimpleSSHD.curr != null) { + SimpleSSHD.curr.runOnUiThread(new Runnable() { public void run() { - activity.update_startstop(); + SimpleSSHD.curr.update_startstop(); } }); }