This is my receiver file
package com.example.tony.headsetplug;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MusicIntentReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
Log.i("Tag","got receiver");
}
}
I am trying to implement a static broadcast for plugging in the headset, my manifest file where the static broadcast is defined.
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name=".MusicIntentReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.headset_plug" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
It's not working, not even showing a broadcast received.