1

I am getting a android usb host permission confirmation dialog when I am establishing the USB connection from my android application.

PendingIntent mPermissionIntent = PendingIntent.getBroadcast(
                        context.getApplicationContext(), 0, new Intent(
                                ACTION_USB_PERMISSION), 0);
                IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
                context.getApplicationContext().registerReceiver(mUsbReceiver,
                        filter);
                manager.requestPermission(driver.getDevice(), mPermissionIntent);

I want to implement that when the user clicks outside the dialog, the dialog will not be dismissed. What do I have to do for this? How to set setCanceledOnTouchOutside(false); for usb host permission confirmation dialog?

  • 1
    Hey bro start a bounty for this question..Its a very good question. – DJphy May 11 '15 at 15:09
  • 1
    One option u have, that is u either want a OK or Cancel to be clicked by the user so that u can receive the option selected by the user through ur registered receivers. But 1 more info i would like to give is that, even if the user clicks outside the dialog box u will receive cancel being selected by user through ur same receiver. So the stuff ur trying to achieve will be possible – DJphy May 16 '15 at 06:06
  • @DJphy - Sorry for late response, I have tried all possible ways fro workaround but nothing work for me and yes app is receiving cancel broadcast in the same receiver. I put the patch for workaround as suggested by you. Thanks –  Jan 10 '17 at 10:06
  • 1
    Ah niice, welcome ! – DJphy Jan 10 '17 at 21:26

1 Answers1

0

The dialog hide trigger the same event of Cancel button. You can just check if the access is denied and study a logic to show again the authorization dialog or a custom dialog to inform the user that the app works just if he authorize USB access.

MartinLoren
  • 61
  • 1
  • 6