Sending an intent from non-Activity extented class

Discussion in 'Application Development' started by soulreaver1, Oct 29, 2012.

  1. soulreaver1

    soulreaver1 Member
    25

    Oct 19, 2012
    6
    0
    25
    Male
    Warsaw, Poland
    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 (Text):
    1. public class MainActivity extends Activity {
    2. ...
    3. CallReceiver mCallReceiver = new CallReceiver();
    4. // call my CallReceiver here
    5. ...
    6. }
    Code (Text):
    1.  
    2. public class CallReceiver extends BroadcastReceiver  {
    3. ...
    4. Intent intent = new Intent(CallReceiver.this, DisplayMessageActivity.class);
    5. // I'd like to send an intent from here to update MainAction.java view.
    6. }
    7.  
     

    Advertisement

Share This Page

Loading...