3

I am new to android. I am trying to detect usb attached to android device. When the usb is attached for first time, the specifiec app opens up.(Working fine).

Now what I am tryng to do is if the app already opened,and a usb device is attached,it should give me a toast that "device is attached".

Can anybody help how to do that. I have tried using onNewIntetnt() to check the intent returned but still not getting toast. plz help

protected void onNewIntent(Intent intent) {
        // TODO Auto-generated method stub
        super.onNewIntent(intent);
        if (intent.getAction().equals(DongleManager.ACTION_USB_DEVICE_ATTACHED)) {
            Slog.d(TAG, "USB ATTACHED");
            Toast.makeText(this, "USB ATTACHED", Toast.LENGTH_SHORT).show();
        }

    }
Amrit
  • 49
  • 3

0 Answers0