0

I am developing one application for that I made some changes in CallCard.java class of Phone application. You can find this class here <http://www.netmite.com/android/mydroid/packages/apps/Phone/src/com/android/phone/CallCard.java>. In the above class there are some cases. i.e BUSY, NUMBER_UNREACHABLE and POWER_OFF etc. In the case of POWER_OFF I called a method of a below class.

public class MyClass extends Activity{ 



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        System.out.println("**inside myclass");

    }

    public  void  powerOff(Context c){
        System.out.println("**inside powerOff");
        Intent call = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:+5555")); 
        startActivity(call);
    }

}

This is my own class and added into source directory Phone application. The code is like this:

case POWER_OFF:
   resID = R.string.callFailed_powerOff;
   MyClass myClass = new MyClass();
   if(myClass != null){
       System.out.println("**not null");
        myClass.powerOff(getContext);
    }
   break;

The reason to do this is, I want to Call other number of same person when first-dialed number is switched_off(currentl hard-coded number). I think this is only one way to this.!! Finaly I started build the code but got some error. i.e 'Cannot find symbol'

Symbol: variable getContext
Location: com.android.phone.
    myClass.powerOff(getContext);
                     ^

Is my way correct? and why this error. plz help me

5
  • MyClass is my own class in which powerOff method is calling from android source code i.e CallCard.java. u can find that class in a mentioned link. thanks a lot Commented Jan 13, 2012 at 5:01
  • My question is - Is MyClass a sub-class of FrameLayout (or any view) or Actrivity? Commented Jan 13, 2012 at 5:03
  • actualy CallCard.java is extends FrameLayout. It's not an activity. Commented Jan 13, 2012 at 5:07
  • So method call must be myClass.powerOff(getContext()); or myClass.powerOff(this.getContext()); Commented Jan 13, 2012 at 5:09
  • Is this correct way what I am doing??. Commented Jan 13, 2012 at 5:11

2 Answers 2

1

Isn't getContext a method? IMO using getContext() should work. Or, according to this, you might want tweak it a bit more.

Sign up to request clarification or add additional context in comments.

1 Comment

IMO should be ok (or as per @nandeesh's variant below). It's just a program :)
0

You have to use getBaseContext() instead of getContext variable

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.