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 (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
Loading...

Share This Page