1. Welcome to the newer, better version of Android Forums! Be sure to see the announcement and enjoy checking it out!

    Some of you have been having login issues. - Please try now. Sorry for the trouble!
  2. All attachments uploaded on the first day of this new look need to be re-uploaded, or will appear broken. All prior to that, and all going forward, should work fine. We apologize for the inconvenience!

Sending an intent from non-Activity extented class


  1. soulreaver1

    soulreaver1 Member

    I've two classes: MainActivity.java and CallReceiver.java . The problem is I can't send an intent from CallReceiver class. Eclipse throws an error: "The constructor error Intent(CallReceiver, Class<MainActivity>) is undefinied.

    Code:
    public class MainActivity extends Activity {
    ...
    CallReceiver mCallReceiver = new CallReceiver(); 
    // call my CallReceiver here
    ...
    }
    Code:
    public class CallReceiver extends BroadcastReceiver  {
    ...
    Intent intent = new Intent(CallReceiver.this, DisplayMessageActivity.class); 
    // I'd like to send an intent from here to update MainAction.java view.
    }
    

    Advertisement

Share This Page