title: Stop app being restarted in response to a USB event when it's already in the foreground
body: <p><strong>Events:</strong> </p>
  
  <p>1.USB device plugged in.</p>
  
  <ol start="2">
  <li>Prompt appears saying: "Open appName when this USB device is connected?"</li>
  <li>Press cancel -> app stays open | press okay -> app restarts</li>
  </ol>
  
  <p><strong>Required behaviour:</strong> The app either does not show the dialog and automatically opens the app when it's not in the foreground, or, when the app is in the foreground then when the user presses okay the app does not restart. </p>
  
  <p><strong>Attempted solution:</strong> I've tried making sure every Activity's launch mode is set to <code>"SingleTask"</code>. This solution worked <a href="https://stackoverflow.com/questions/15206064/preventing-main-activity-from-being-launched-if-running-already.">here</a> but when I did the same thing the app still restarted. </p>
  
  <p><strong>Question in a nutshell:</strong> How do I stop my app restarting when the user says to open the app when the device is connected? Or, how do I stop this prompt entirely whilst still enabling my app to start when this USB device is connected? </p>
  
  <p>I've seen similar questions which deal with stopping a prompt showing which asks whether the app should be allowed to access the connected device, but, my issue is dealing with a different prompt.</p>
  
  <p>Thanks in advance.</p>