Skip to content

Commit

Permalink
prevent force close if service restarted
Browse files Browse the repository at this point in the history
  • Loading branch information
arifhn committed Feb 1, 2012
1 parent 7a290e4 commit de8615b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="/home/android-sdk-linux_86/extras/android/compatibility/v4/android-support-v4.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
6 changes: 5 additions & 1 deletion src/mobi/cyann/nstools/services/BlnObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public void onReceive(Context context, Intent intent) {

@Override
public void stopWatching() {
context.unregisterReceiver(alarmReceiver);
try {
context.unregisterReceiver(alarmReceiver);
}catch(Exception ex) {
Log.d(LOG_TAG, "exception when unregister receiver", ex);
}
super.stopWatching();
}
}
6 changes: 4 additions & 2 deletions src/mobi/cyann/nstools/services/ObserverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.provider.CallLog.Calls;
import android.util.Log;

/**
Expand All @@ -30,7 +29,10 @@ public IBinder onBind(Intent intent) {

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent.getAction();
String action = null;
if(intent != null) {
action = intent.getAction();
}
if(action != null && action.equals("STOP")) {
Log.d(LOG_TAG, "stoping service");
if(blnObserver != null) {
Expand Down

0 comments on commit de8615b

Please sign in to comment.