Browse Source

Fix service starting breaking activity

Closes #60
tags/ActivityRecorder/0.1.2
Chris Smith 14 years ago
parent
commit
c2472ff2c8

BIN
code/ActivityRecorder/dist/ActivityRecorder.apk View File


+ 12
- 3
code/ActivityRecorder/src/uk/co/md87/android/activityrecorder/ActivityRecorderActivity.java View File

@@ -60,6 +60,15 @@ public class ActivityRecorderActivity extends Activity {
60 60
         }
61 61
     };
62 62
 
63
+    private final Runnable startRunnable = new Runnable() {
64
+
65
+        public void run() {
66
+            startService(new Intent(ActivityRecorderActivity.this,
67
+                    RecorderService.class));
68
+            updateRunnable.run();
69
+        }
70
+    };
71
+
63 72
     private OnClickListener clickListener = new OnClickListener() {
64 73
 
65 74
         public void onClick(View arg0) {
@@ -71,9 +80,9 @@ public class ActivityRecorderActivity extends Activity {
71 80
                     bindService(new Intent(ActivityRecorderActivity.this, RecorderService.class),
72 81
                             connection, BIND_AUTO_CREATE);
73 82
                 } else {
74
-                    startService(new Intent(ActivityRecorderActivity.this,
75
-                            RecorderService.class));
76
-                    handler.postDelayed(updateRunnable, 500);
83
+                    handler.removeCallbacks(updateRunnable);
84
+                    ((Button) findViewById(R.id.togglebutton)).setEnabled(false);
85
+                    handler.postDelayed(startRunnable, 500);
77 86
                 }
78 87
             } catch (RemoteException ex) {
79 88
                 Log.e(getClass().getName(), "Unable to get service state", ex);

Loading…
Cancel
Save