title: Capturing Bluetooth Headset longpress event in android
body: <p>I want to launch my Main activity when the Bluetooth button is longpressed, much like how Google Voice launches when you longpress the BT button but I can't seem to find the right action to trigger it.</p>
  
  <p>my current code:</p>
  
  <pre><code>public class LaunchReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          Log.d("HERE", action);
      }
  }
  </code></pre>
  
  <p>In manifest:</p>
  
  <pre><code>    &lt;receiver
          android:name="com.app.LaunchReceiver"
          android:enabled="true" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED" /&gt;
              &lt;action android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" /&gt;
              &lt;action android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" /&gt;
              &lt;action android:name="android.intent.action.VOICE_COMMAND" /&gt;
              &lt;action android:name="android.intent.action.WEB_SEARCH" /&gt;
              &lt;action android:name="android.intent.action.MEDIA_BUTTON" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>Right now, with the above code, the only action that displays is CONNECTION_STATE_CHANGED, but that also happens when you turn on/off the headset. I've been trying the other answers in stackoverflow with no success.</p>
  
  <p>--- edit --- the solution to this was to:</p>
  
  <pre><code>    &lt;activity
          android:name="com.app.LaunchActivity"
          android:label="@string/app_name"&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 android:priority="2147483647"&gt;
              &lt;action android:name="android.intent.action.VOICE_COMMAND" /&gt;
  
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>and disable S voice in application manager.</p>