Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. //....................
  2. static TextView console;
  3.  
  4. // A callback for received data must be defined
  5. private UsbSerialInterface.UsbReadCallback mCallback = new UsbSerialInterface.UsbReadCallback() {
  6. @Override
  7. public void onReceivedData(byte[] dat) {
  8. String data = new String(dat);
  9.  
  10. console.append("RECEIVED DATA: "+data+"n"); //HERE IT CRASHING
  11.  
  12. if (data.startsWith("call ")) {
  13. Intent callIntent = new Intent(Intent.ACTION_CALL);
  14. callIntent.setData(Uri.parse("tel:"+data.split(" ")[1]));
  15. try {
  16. startActivity(callIntent);
  17. console.append("Calling "+data.split(" ")[1]+" ...n");
  18. } catch (Exception e) { console.append("ERROR: Cant call "+data.split(" ")[1]+" ...n");}
  19. }
  20. }
  21. };
  22.  
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26. setContentView(R.layout.activity_main);
  27.  
  28. final Button btn = (Button) findViewById(R.id.btn);
  29. final TextView console = (TextView) findViewById(R.id.console);
  30. //...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement