Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //....................
- static TextView console;
- // A callback for received data must be defined
- private UsbSerialInterface.UsbReadCallback mCallback = new UsbSerialInterface.UsbReadCallback() {
- @Override
- public void onReceivedData(byte[] dat) {
- String data = new String(dat);
- console.append("RECEIVED DATA: "+data+"n"); //HERE IT CRASHING
- if (data.startsWith("call ")) {
- Intent callIntent = new Intent(Intent.ACTION_CALL);
- callIntent.setData(Uri.parse("tel:"+data.split(" ")[1]));
- try {
- startActivity(callIntent);
- console.append("Calling "+data.split(" ")[1]+" ...n");
- } catch (Exception e) { console.append("ERROR: Cant call "+data.split(" ")[1]+" ...n");}
- }
- }
- };
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- final Button btn = (Button) findViewById(R.id.btn);
- final TextView console = (TextView) findViewById(R.id.console);
- //...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement