title: Android USB Permissions Dialog never appears
body: <p>I've written a simple app to send commands to a USB printer connected to an Android 4.0 tablet via USB. For some reason, I am unable to get past obtaining permissions to claim an interface and open a connection. Here's the relevant code : </p>
  
  <pre><code>public class TestPrintActivity extends Activity {
  
  private UsbManager mUsbManager;
  private UsbDevice mDevice;
  private UsbDeviceConnection mConnection;
  private UsbInterface mInterface;
  private UsbEndpoint mBulkIn;
  private UsbEndpoint mBulkOut;
  private static final String ACTION_USB_PERMISSION =
          "com.demo.xprinter.USB_PERMISSION";
  private PendingIntent mPermissionIntent;
  private BroadcastReceiver mUsbReceiver; 
  
  @Override
  
  private static final String ACTION_USB_PERMISSION =
          "com.demo.printerDemo.USB_PERMISSION";
  
  
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_test_print);
  
      mUsbManager = (UsbManager)getSystemService(Context.USB_SERVICE);
  
      mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
      IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
      filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
      filter.addAction(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
      registerReceiver(mUsbReceiver, filter);
  
      mUsbReceiver = new BroadcastReceiver() {
  
          public void onReceive(Context context, Intent intent) {
  
              String action = intent.getAction();
              if (ACTION_USB_PERMISSION.equals(action)) {
                  synchronized (this) {
                      UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
  
                      if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
                          if(device != null){
                            //call method to set up device communication
                              openPort(device);
                         }
                      } 
                      else {
                          Toast.makeText(getApplicationContext(), "Denied!", Toast.LENGTH_SHORT).show();
                      }
                  }
              }
          }
      };
  
  }
  
  public void onResume() {
      super.onResume();
  
      HashMap&lt;String,UsbDevice&gt; deviceList = mUsbManager.getDeviceList();
  
      for (HashMap.Entry&lt;String,UsbDevice&gt; entry : deviceList.entrySet()) {
            UsbDevice aDevice = entry.getValue();
            if ((aDevice.getProductId() == 8965) &amp;&amp; (aDevice.getVendorId() == 1659) ){
  
                if (mUsbManager.hasPermission(aDevice))
                  openPort(aDevice);
                else
                  mUsbManager.requestPermission(aDevice, mPermissionIntent);
                break;
            }
          }
  
  
  }
  </code></pre>
  
  <p>Here's the relevant part of the manifest:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.demo.printerDemo"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="14"
      android:targetSdkVersion="17" /&gt;
  &lt;uses-feature android:name="android.hardware.usb.host"/&gt;
  </code></pre>
  
  <p>I've configured the device so that it launches my app whenever the printer is connected, and the device is found during the enumeration (onResume()) and the request for permission is called. However, for whatever reason, I never see the "Request Permission" dialog (I've seen screenshots of it online) nor does onReceive() ever get called. Any ideas why this might be happening? </p>