title: Android - Customised New Incoming Call Screen
body: <p>I'm trying to make an new incoming call screen in android,</p>
  
  <p>when i get an incoming call my app starts - but crashes  immediately, and the default incoming call screen is coming up.</p>
  
  <p>what am i doing wrong?</p>
  
  <p>my code:</p>
  
  <p><strong>AndroidManifest.xml :</strong></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.myfirstapp"
        android:versionCode="7"
        android:versionName="7"&gt;
      &lt;uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10"&gt;&lt;/uses-sdk&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.CALL_PHONE" /&gt;
  
      &lt;application android:label="@string/app_name" android:icon="@drawable/ic_launcher"&gt;
          &lt;receiver android:name=".MyPhoneBroadcastReceiver" android:enabled="true"&gt;
              &lt;intent-filter android:priority="99999"&gt;
                  &lt;action android:name="android.intent.action.PHONE_STATE" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;activity
              android:name=".Call" &gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>MyPhoneBroadcastReceiver.java:</strong></p>
  
  <pre><code>package com.example.myfirstapp;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  
  public class MyPhoneBroadcastReceiver extends Activity{
  
      public void onReceive(final Context context, Intent intent) {
              Intent main_intent = new Intent(this, Call.class);
              context.startActivity(main_intent);
      }
  
  
  }
  </code></pre>
  
  <p><strong>Call.java:</strong></p>
  
  <pre><code>package com.example.myfirstapp;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class Call extends Activity{
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      }
  
  }
  </code></pre>
  
  <p>the log is:</p>
  
  <pre><code> 10-14 20:59:51.056: E/AndroidRuntime(1826): FATAL EXCEPTION: main
   10-14 20:59:51.056: E/AndroidRuntime(1826):
   java.lang.RuntimeException: Unable to instantiate receiver
   com.example.myfirstapp.MyPhoneBroadcastReceiver:
   java.lang.ClassCastException:
   com.example.myfirstapp.MyPhoneBroadcastReceiver cannot be cast to
   android.content.BroadcastReceiver 10-14 20:59:51.056:
   E/AndroidRuntime(1826): at
   android.app.ActivityThread.handleReceiver(ActivityThread.java:2210)
   10-14 20:59:51.056: E/AndroidRuntime(1826): at
   android.app.ActivityThread.access$1500(ActivityThread.java:130) 10-14
   20:59:51.056: E/AndroidRuntime(1826): at
   android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
   10-14 20:59:51.056: E/AndroidRuntime(1826): at
   android.os.Handler.dispatchMessage(Handler.java:99) 10-14
   20:59:51.056: E/AndroidRuntime(1826): at
   android.os.Looper.loop(Looper.java:137) 10-14 20:59:51.056:
   E/AndroidRuntime(1826): at
   android.app.ActivityThread.main(ActivityThread.java:4745) 10-14
   20:59:51.056: E/AndroidRuntime(1826): at
   java.lang.reflect.Method.invokeNative(Native Method) 10-14
   20:59:51.056: E/AndroidRuntime(1826): at
   java.lang.reflect.Method.invoke(Method.java:511) 10-14 20:59:51.056:
   E/AndroidRuntime(1826): at
   com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
   10-14 20:59:51.056: E/AndroidRuntime(1826): at
   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-14
   20:59:51.056: E/AndroidRuntime(1826): at
   dalvik.system.NativeStart.main(Native Method) 10-14 20:59:51.056:
   E/AndroidRuntime(1826): Caused by: java.lang.ClassCastException:
   com.example.myfirstapp.MyPhoneBroadcastReceiver cannot be cast to
   android.content.BroadcastReceiver 10-14 20:59:51.056:
   E/AndroidRuntime(1826): at
   android.app.ActivityThread.handleReceiver(ActivityThread.java:2205)
   10-14 20:59:51.056: E/AndroidRuntime(1826): ... 10 more
  </code></pre>