Skip to content

Instantly share code, notes, and snippets.

@CWrecker
Created March 31, 2019 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CWrecker/9936c8ee1534018b3983939b07995cf5 to your computer and use it in GitHub Desktop.
Save CWrecker/9936c8ee1534018b3983939b07995cf5 to your computer and use it in GitHub Desktop.
Here we are adding the buttons to force serial-connection related functions.
//-------------------------------
//Serial Connection Functions
//----------------------
usbManager = (UsbManager) getSystemService(this.USB_SERVICE);
startButton = (Button) findViewById(R.id.buttonStart);
sendButton = (Button) findViewById(R.id.buttonSend);
orderButton = (Button) findViewById(R.id.btnorder);
clearButton = (Button) findViewById(R.id.buttonClear);
stopButton = (Button) findViewById(R.id.buttonStop);
editText = (EditText) findViewById(R.id.editText);
textView = (TextView) findViewById(R.id.textView);
setUiEnabled(false);
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
registerReceiver(broadcastReceiver, filter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment