title: Android manifest for USBAccesory
body: <p>I am making an app that communicates with a piece of usb hardware made by my company (this is the only app allowed to talk to the usb accessory, it's not a public api). I am having difficulties setting up the proper launch modes in the manifest.</p>
  
  <p>There are three components to the app: the main activity, a login activity, and the USBService.</p>
  
  <p>I'm assuming the intent for the main goes to the login activity, and the intent for the usb goes to the USBService, but I am not sure if I do this, will this start the service if the app is not running?  More over, if it does, how do I fetch an already existing service?</p>
  
  <p>What type of structure should I be looking at for the manifest file? (<strong>specifically, intent-filters, and appropriate launch modes</strong>... I've read a few documents about the launch modes but I am still not sure I quite understand... There should only ever be at most one instance of each activity/service, and they need to communicate together.</p>
  
  <p>edit: it is not necessary for communications to start before the app is open, nor is it necessary to launch the app automatically when the usb is connected.</p>
  
  <p>edit: my manifest as it stands, looks like:</p>
  
   
  
  <p></p>
  
  <pre><code>&lt;uses-feature android:name="android.hardware.usb.accessory" /&gt;
  
  &lt;uses-sdk
      android:minSdkVersion="15"
      android:targetSdkVersion="17" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" &gt;
      &lt;activity
          android:name="mainpackage.MainActivity"
          android:label="@string/app_name" 
          android:launchMode="singleTop"&gt;
          &lt;intent-filter&gt; 
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /&gt;
          &lt;/intent-filter&gt;
              &lt;meta-data
              android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
              android:resource="@xml/accessory_filter" /&gt;
  
      &lt;/activity&gt;
      &lt;activity
          android:name="mainpackage.LoginActivity"
          android:label="@string/title_activity_login"
          android:windowSoftInputMode="adjustResize|stateVisible" &gt;
      &lt;/activity&gt;
  
      &lt;service android:name="updater.USBService"
          android:exported="false" &gt;
  
          &lt;!--  
  
              --&gt;
      &lt;/service&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>