In my main activity I am having a method that I need to call from a secondary java class. I used the constructor of the secondary java class to receive reference to the main Activity. I then tried to use this reference to invoke that method from the body of the secondary java class. But java doesn't recognize that method through the passed reference?
My main Activity is as below: public class MainActivity extends Activity{ public void onCreate(){ TestClass mTestClass = new TestClass(this); <br/> } public testMethod(){ // do some work here } } now, in my TestClass.java I receive reference to the MainActivity: public class TestClass{ public TestClass(Activity mActivity){ mActivity.testMethod(); //Android/Java doesn't recoginze testMethod here???? } } I've been trying to solve this issue for a few days with no success. I urgently need your help and would appreciate any suggestion! P.S. The TestClass will act as a library that everyone can call it from their android application. In other words, I provide the TestClass as the library. The user then implements the content of a method that will be executed whenver certain conditions are met. Thus, I need to call that specific method (which will be defined by the user in their own Activity) through a reference which is passed by the user to my library class -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en