title: USB Permissions without prompt
body: <p>I have 2 activities within my app. Say <code>FirstActivity</code> and <code>SecondActivity</code>.  <code>FirstActivity</code> is the MAIN and LAUNCHER activity. <code>SecondActivity</code> uses usb devices. I want the prompt for USB permission to appear only once within lifetime of the app. </p>
  
  <p>If there was only one Activity, the following lines in manifest solved my purpose: </p>
  
  <pre><code>&lt;activity android:name=".FirstActivity"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /&gt;
      &lt;/intent-filter&gt;
  
      &lt;meta-data
          android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
          android:resource="@xml/usb_device_filter" /&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p>This was doing the following:</p>
  
  <ol>
  <li>Launching FirstActivity whenever usb device (mentioned in xml) is connected is app is not already open.</li>
  <li>Prompt for usb device permission appears only once.</li>
  </ol>
  
  <p>How do I modify this to achieve the following: </p>
  
  <ol start="3">
  <li><p>If SecondActivity is already running and a new usb device is attached, I must be able to use the device without relaunching the app. So I have written a broadcast receiver for the same as follows: </p>
  
  <pre><code>public class TriggerReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) { 
          read connected usb devices and register serial port call listener back.
      }
  }    
  </code></pre></li>
  </ol>
  
  <p>But the problem is <code>FirstActivity</code> gets relaunched again when usb device is attached while <code>SecondActivity</code> is running. How do I avoid this ?</p>
  
  <p>Will add more information if needed. Would be thankful for any help. </p>