title: Why isn't the broadcast receiver working? I have tried quite a few solutions posted in this site as well in others however it isn't working. Help me
body: <p>This is my code in the Broadcast receiver class</p>
  
  <pre><code>package com.example.manjit.myapplication;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.util.Log;
  import android.widget.Toast;
  
  public class MyReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          Toast.makeText(context, "working!!", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>And the manifest file contains the following code </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.manjit.myapplication"&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;receiver
              android:name=".MyReceiver"
              android:enabled="true"
              android:exported="true"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"&gt;&lt;/action&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>I have tried the code with many actions such as <code>action android:name="android.intent.action.HEADSET_PLUG"</code> but the toast is not displayed. Please help me out. I have tried running on Lolipop</p>