189
+        App.getAppContext().startService(intent);
190
+        conn = new PrinterServiceConnection();
191
+        App.getAppContext().bindService(intent, conn, Context.BIND_AUTO_CREATE);
109 192
     }
110 193
 
111 194
     // changes the title when discovery is finished
@@ -131,6 +214,30 @@ public class PrinterSettingPresenter implements PrinterSettingContract.Presenter
131 214
         }
132 215
     };
133 216
 
217
+    private void registerPrinterBroadcast() {
218
+        IntentFilter filter = new IntentFilter();
219
+        filter.addAction(GpCom.ACTION_CONNECT_STATUS);
220
+        context.registerReceiver(PrinterStatusBroadcastReceiver, filter);
221
+    }
222
+
223
+    private BroadcastReceiver PrinterStatusBroadcastReceiver = new BroadcastReceiver() {
224
+        @Override
225
+        public void onReceive(Context context, Intent intent) {
226
+            if (GpCom.ACTION_CONNECT_STATUS.equals(intent.getAction())) {
227
+                int type = intent.getIntExtra(GpPrintService.CONNECT_STATUS, 0);
228
+                int id = intent.getIntExtra(GpPrintService.PRINTER_ID, 0);
229
+                Log.d("czy", "connect status " + type);
230
+                if (type == GpDevice.STATE_CONNECTING) {
231
+
232
+                } else if (type == GpDevice.STATE_NONE) {
233
+
234
+                } else if (type == GpDevice.STATE_VALID_PRINTER) {
235
+
236
+                } else if (type == GpDevice.STATE_INVALID_PRINTER) {
134 237
 
238
+                }
239
+            }
240
+        }
241
+    };
135 242
 
136 243
 }

Sign In - Gogs: Go Git Service

Sign In