Skip to content
Snippets Groups Projects
Commit fae29bd3 authored by Emeric Vigier's avatar Emeric Vigier
Browse files

#14652: fix start and stop service

parent 2c50e690
Branches
Tags
No related merge requests found
...@@ -164,10 +164,11 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -164,10 +164,11 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
// Reverse // Reverse
animation.setRepeatMode(Animation.REVERSE); animation.setRepeatMode(Animation.REVERSE);
/* startService() can be called any number of times without harm */ if (!serviceIsOn) {
Log.i(TAG, "starting SipService"); Log.i(TAG, "starting SipService");
startSipService(); startSipService();
} }
}
@Override @Override
protected void onStart() { protected void onStart() {
...@@ -175,7 +176,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -175,7 +176,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
super.onStart(); super.onStart();
// Bind to LocalService // Bind to LocalService
if (!mBound) { if (!mBound) {
Log.d(TAG, "Binding service..."); Log.i(TAG, "onStart: Binding service...");
Intent intent = new Intent(this, SipService.class); Intent intent = new Intent(this, SipService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE); bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
} }
...@@ -206,7 +207,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -206,7 +207,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
super.onStop(); super.onStop();
/* stop the service, if no other bound user, no need to check if it is running */ /* stop the service, if no other bound user, no need to check if it is running */
if (mBound) { if (mBound) {
Log.d(TAG, "Unbinding service..."); Log.i(TAG, "onStop: Unbinding service...");
unbindService(mConnection); unbindService(mConnection);
mBound = false; mBound = false;
} }
...@@ -215,6 +216,8 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -215,6 +216,8 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
/* activity finishes itself or is being killed by the system */ /* activity finishes itself or is being killed by the system */
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.i(TAG, "onDestroy: stopping SipService...");
stopService(new Intent(this, SipService.class));
serviceIsOn = false; serviceIsOn = false;
super.onDestroy(); super.onDestroy();
} }
...@@ -243,6 +246,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -243,6 +246,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
Intent sipServiceIntent = new Intent(SFLPhoneHome.this, SipService.class); Intent sipServiceIntent = new Intent(SFLPhoneHome.this, SipService.class);
//sipServiceIntent.putExtra(ServiceConstants.EXTRA_OUTGOING_ACTIVITY, new ComponentName(SFLPhoneHome.this, SFLPhoneHome.class)); //sipServiceIntent.putExtra(ServiceConstants.EXTRA_OUTGOING_ACTIVITY, new ComponentName(SFLPhoneHome.this, SFLPhoneHome.class));
startService(sipServiceIntent); startService(sipServiceIntent);
serviceIsOn = true;
}; };
}; };
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment