title: Incoming text activates button
body: <p>I have an app that I'm trying to set up so that when I receive a text containing a certain phrase (Currently set to "This is a test" just to test it), a button onClick event will fire.  If my message receiver was in my main activity, I could simply call .performClick().  However, I cant get it to work unless the message receiver is in a seperate class.</p>
  
  <p>MessageReceiver.java</p>
  
  <pre><code>package com.defsoftsol.snow.alert;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.telephony.SmsMessage;
  import android.util.Log;
  import android.widget.Toast;
  
  public class MessageReceiver extends BroadcastReceiver 
  {
      public void onReceive(Context context, Intent intent) 
      {
          Bundle pudsBundle = intent.getExtras();
          Object[] pdus = (Object[]) pudsBundle.get("pdus");
          SmsMessage messages =SmsMessage.createFromPdu((byte[]) pdus[0]);    
          Log.i("MessageBody",  messages.getMessageBody());
          if(messages.getMessageBody().contains("This is a test")) 
          {
              Toast.makeText(context, "It worked", Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>
  
  <p>How can I do a performClick() on a button thats in MainActivity.java?  Can I somehow access the View from that class?</p>
  
  <p>manifest entry</p>
  
  <pre><code>&lt;receiver android:name=".MainActivity.MessageReceiver" android:exported="true"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.provider.Telephony.SMS_RECEIVED"&gt;&lt;/action&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>Logcat from crash when receive text with receiver in mainactivity.java</p>
  
  <pre><code>01-30 20:31:57.002: E/AndroidRuntime(32555): FATAL EXCEPTION: main
  01-30 20:31:57.002: E/AndroidRuntime(32555): java.lang.RuntimeException: Unable to instantiate receiver com.defsoftsol.snow.alert.MainActivity.MessageReceiver: java.lang.ClassNotFoundException: com.defsoftsol.snow.alert.MainActivity.MessageReceiver
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2100)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.os.Handler.dispatchMessage(Handler.java:99)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.os.Looper.loop(Looper.java:137)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.app.ActivityThread.main(ActivityThread.java:4428)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at java.lang.reflect.Method.invokeNative(Native Method)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at java.lang.reflect.Method.invoke(Method.java:511)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at dalvik.system.NativeStart.main(Native Method)
  01-30 20:31:57.002: E/AndroidRuntime(32555): Caused by: java.lang.ClassNotFoundException: com.defsoftsol.snow.alert.MainActivity.MessageReceiver
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2095)
  01-30 20:31:57.002: E/AndroidRuntime(32555):    ... 10 more
  </code></pre>