title: intentservice doesn't work as I expected it to
body: <p>I made a small app that would receive ringer mode change broadcasts and then display a small toast whenever it is received. Although it can be achieved by using only a single activity, I intend to use an intentservice. However, the intentservice I made is making the app crash everytime, and there hasn't been a single successful run. </p>
  
  <p>The MainActivity.java file:</p>
  
  <pre><code>package com.example.android.servicepractice;
  
  import android.content.ComponentName;
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  
  public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Intent serviceIntent = new Intent();
  serviceIntent.setAction("com.example.android.servicepractice.AudioService");
      startService(serviceIntent);
  
  }
  }
  </code></pre>
  
  <p>The AudioService.java file</p>
  
  <pre><code>package com.example.android.servicepractice;
  
  import android.app.IntentService;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.media.AudioManager;
  import android.widget.Toast;
  
  public class AudioService extends IntentService{
  
  public BroadcastReceiver receiver;
  
  //First requirement is a constructor
  public AudioService(){
      super("AudioService");
  }
  
  //This is the function that is called when the service is created
  @Override
  public void onHandleIntent(Intent intent){
      //Work that needs to be done
      receiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              Toast.makeText(getApplicationContext(), "Audio Mode Changed", Toast.LENGTH_SHORT).show();
          }
      };
  
      IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
      registerReceiver(receiver, filter);
      }
   }
  </code></pre>
  
  <p>The AndroidManifest.xml file</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.android.servicepractice"&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;activity android:name=".MainActivity"&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;/activity&gt;
      &lt;service android:name=".AudioService"
          android:label="@string/app_name"
          android:enabled="true"/&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>I am new to android, and this is my first time using intentservices, so I wanted to know what would be the better alternative for use here, Services or IntentServices? Also, what am I doing wrong here that the app keeps on crashing?</p>