title: BroadCastReceiver Force Close For Sms receive
body: <p>I am creating just a simple android app which will respond to received.
  I am using braodcastreceiver to receive sms.
  Code for activity is </p>
  
  <pre><code>package com.om;
  
  import android.app.Activity;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.os.Bundle;
  import android.widget.Toast;
  import android.telephony.SmsManager;
  import android.telephony.SmsMessage;
  
  public class MyTest extends Activity {
    public static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
    /** Called when the activity is first created. */
    BroadcastReceiver smsReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context _context, Intent _intent) {
        System.out.println("SMS Received");
      }
    };
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        IntentFilter filter = new IntentFilter(SMS_RECEIVED);
        registerReceiver(smsReceiver, filter);
    }
  }
  </code></pre>
  
  <p>When I run this activity on SDK 2.1 AVD and sends SMS to that port it says Force close.
  Please tell me what is error in code.
  Thanks in advance.</p>