From ef0616a143e7c5ec179ffa00f0f86e0a4ae3cc35 Mon Sep 17 00:00:00 2001 From: Graham Jones Date: Mon, 25 Jul 2016 22:24:26 +0100 Subject: [PATCH] Added system logging to MainActivity and PrefActivity --- .../org/openseizuredetector/MainActivity.java | 17 ++++++++++++++--- .../org/openseizuredetector/PrefActivity.java | 6 ++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/uk/org/openseizuredetector/MainActivity.java b/app/src/main/java/uk/org/openseizuredetector/MainActivity.java index 1c4e5d5..5dd5afa 100644 --- a/app/src/main/java/uk/org/openseizuredetector/MainActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/MainActivity.java @@ -98,6 +98,9 @@ public class MainActivity extends Activity { //int i = 5/0; // Force exception to test handler. mUtil = new OsdUtil(this,serverStatusHandler); mConnection = new SdServiceConnection(this); + mUtil.writeToSysLogFile(""); + mUtil.writeToSysLogFile("* MainActivity Started *"); + mUtil.writeToSysLogFile("MainActivity.onCreate()"); // Initialise the User Interface setContentView(R.layout.main); @@ -257,6 +260,7 @@ public class MainActivity extends Activity { @Override protected void onStart() { super.onStart(); + mUtil.writeToSysLogFile("MainActivity.onStart()"); SharedPreferences SP = PreferenceManager .getDefaultSharedPreferences(getBaseContext()); boolean audibleAlarm = SP.getBoolean("AudibleAlarm", true); @@ -267,18 +271,21 @@ public class MainActivity extends Activity { String versionName = mUtil.getAppVersionName(); tv.setText("OpenSeizureDetector Server Version " + versionName); + mUtil.writeToSysLogFile("MainActivity.onStart - Binding to Server"); mUtil.bindToServer(this, mConnection); - } @Override protected void onStop() { super.onStop(); + mUtil.writeToSysLogFile("MainActivity.onStop()"); mUtil.unbindFromServer(this, mConnection); } private void startServer() { + mUtil.writeToSysLogFile("MainActivity.startServer()"); + Log.v(TAG, "starting Server..."); mUtil.startServer(); // Change the action bar icon to show the option to stop the service. if (mOptionsMenu != null) { @@ -292,6 +299,7 @@ public class MainActivity extends Activity { } private void stopServer() { + mUtil.writeToSysLogFile("MainActivity.stopServer()"); Log.v(TAG, "stopping Server..."); mUtil.stopServer(); // Change the action bar icon to show the option to start the service. @@ -611,15 +619,18 @@ public class MainActivity extends Activity { @Override protected void onPause() { super.onPause(); + mUtil.writeToSysLogFile("MainActivity.onPause()"); } @Override protected void onResume() { super.onResume(); + mUtil.writeToSysLogFile("MainActivity.onResume()"); } private void showAbout() { + mUtil.writeToSysLogFile("MainActivity.showAbout()"); View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false); String versionName = mUtil.getAppVersionName(); Log.v(TAG, "showAbout() - version name = " + versionName); @@ -631,11 +642,11 @@ public class MainActivity extends Activity { builder.show(); } - class ResponseHandler extends Handler { + static class ResponseHandler extends Handler { @Override public void handleMessage(Message message) { Log.v(TAG, "Message=" + message.toString()); } - } + } } diff --git a/app/src/main/java/uk/org/openseizuredetector/PrefActivity.java b/app/src/main/java/uk/org/openseizuredetector/PrefActivity.java index e19a296..0fff372 100644 --- a/app/src/main/java/uk/org/openseizuredetector/PrefActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/PrefActivity.java @@ -57,6 +57,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference mContext = getApplicationContext(); mUtil = new OsdUtil(mContext,mHandler); + mUtil.writeToSysLogFile("PrefActvity.onCreate()"); } /** @@ -108,6 +109,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference @Override public void onStart() { super.onStart(); + mUtil.writeToSysLogFile("PrefActvity.onStart()"); invalidateHeaders(); Log.v(TAG, "onStart()"); } @@ -123,6 +125,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference @Override public void onResume() { super.onResume(); + mUtil.writeToSysLogFile("PrefActvity.onResume()"); Log.v(TAG, "onResume()"); SharedPreferences SP = PreferenceManager .getDefaultSharedPreferences(getBaseContext()); @@ -132,6 +135,7 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference @Override protected void onPause() { super.onPause(); + mUtil.writeToSysLogFile("PrefActvity.onPause()"); SharedPreferences SP = PreferenceManager .getDefaultSharedPreferences(getBaseContext()); SP.unregisterOnSharedPreferenceChangeListener(this); @@ -140,8 +144,10 @@ public class PrefActivity extends PreferenceActivity implements SharedPreference @Override protected void onDestroy() { super.onDestroy(); + mUtil.writeToSysLogFile("PrefActvity.onDestroy()"); Log.v(TAG, "onDestroy. mPrefChanged=" + mPrefChanged); if (mPrefChanged) { + mUtil.writeToSysLogFile("PrefActvity.onDestroy() - settings changed - re-starting...."); mUtil.showToast("Settings Changed - re-starting OpenSeizureDetector...."); Intent intent = new Intent(getApplicationContext(), StartupActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);