public void registerDeviceCallback(DeviceCallback callback, Handler handler) { if (mUseProxy) { // Keep our own list of callbacks. mCallbacks.put(callback, handler); } else { mMidiManager.registerDeviceCallback(callback, handler); } }
private MidiDeviceMonitor(MidiManager midiManager) { mMidiManager = midiManager; if (mUseProxy) { Log.i(TAG,"Running on M so we need to use the workaround."); mMyDeviceCallback = new MyDeviceCallback(); mMidiManager.registerDeviceCallback(mMyDeviceCallback, new Handler(Looper.getMainLooper())); } }
private void setupMidi() { // Setup MIDI mMidiManager = (MidiManager) getSystemService(MIDI_SERVICE); mMidiManager.registerDeviceCallback(new DeviceCallback() { @Override public void onDeviceRemoved(final MidiDeviceInfo info) { mOpenDeviceListAdapter.remove(info); } // Update port open counts so user knows if the device is in use. @Override public void onDeviceStatusChanged(final MidiDeviceStatus status) { MidiDeviceInfo info = status.getDeviceInfo(); BluetoothMidiDeviceTracker tracker = mOpenDeviceListAdapter .getDevice(info); if (tracker != null) { tracker.outputOpenCount = 0; for (int i = 0; i < info.getOutputPortCount(); i++) { tracker.outputOpenCount += status .getOutputPortOpenCount(i); } tracker.inputOpenCount = 0; for (int i = 0; i < info.getInputPortCount(); i++) { tracker.inputOpenCount += status.isInputPortOpen(i) ? 1 : 0; } mOpenDeviceListAdapter.notifyDataSetChanged(); } } }, new android.os.Handler(Looper.getMainLooper())); }
mSpinner.setAdapter(mAdapter); mMidiManager.registerDeviceCallback(this, new Handler(Looper.getMainLooper()));
mSpinner.setAdapter(mAdapter); mMidiManager.registerDeviceCallback(this, new Handler(Looper.getMainLooper()));