I did not read the code closely enough to see what is going wrong or why. But I did notice one thing: yet again, you are assuming you - must- extend Application, without any clear reason why.
Indeed: since Shane already explained how to get the current Application using getApplication(), I am surprised you see a need to - extend- Application at all. You do not. All you need to do is call getApplication() to get the Application hosting the Activity. And you can do this from any of its Activities, of which there could be many (this, BTW, is why you do not want to inherit from both). If you must, you can implement the Application yourself in AndroidManifest.xml using the <application> tag. But I don't think we know enough yet about what you are trying to do to say whether or not this is what you should be doing. Finally, reiterating what others have said, in somewhat different words: you do not need multiple inheritance. The classes and interfaces of Android were well designed, certainly well enough that you do not need a feature the language itself does not even support. If you think you do need it, then you have not understood the classes, draw yourself CRC cards of them or UML diagrams to shed more light on them. And don't forget to consider the has-a instead of is-a relationship (composition vs. inheritance). On Jul 30, 1:02 pm, Priyank Maiya <priyankvma...@gmail.com> wrote: > Hi, > I am facing some when running the code. I am using the > getApplicationContext() to save the instance. > Kindly have a look at my code and let me know where I am going wrong. > > VVMService is the class whose instance is created and got from the > onServiceConnected() callback > > public class VVMServiceBind extends Activity > { > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > bindService(new Intent(VVMServiceBind.this, VVMService.class), > mConnection, Context.BIND_AUTO_CREATE); > VVMService appState = ((VVMService)getApplicationContext()); > } > > public void onServiceConnected(ComponentName className, IBinder > service) > { > Log.i(TAG, "In onServiceConnected"); > mService = ((VVMService.VVMBinder)service).getService(); > appState = mService; > > } > > } > > VVMClientApplication is the class where I need to access the VVMService > class instance. > > public void serviceConnectionSuccess() > { > private VVMService mService; > > mService = (VVMService)getApplicationContext(); > > } > > dont I have to extend Application in any class ? > > Thanks, > Priyank > > On Fri, Jul 30, 2010 at 12:45 PM, Shane Isbell <shane.isb...@gmail.com>wrote: > > > Just invoke Activity.getApplication() within your Activity.onCreate method, > > casting the Application to your specific class type. Then your can set > > whatever you need on your application instance and it will be accessible > > within other Activities through the same Activity.getApplication() method. > > >http://developer.android.com/reference/android/app/Activity.html#getA... > > > On Fri, Jul 30, 2010 at 10:29 AM, Priyank <priyankvma...@gmail.com> wrote: > > >> Hi, > >> I had a basic question. > >> Can my class extend 2 or more classes at a time. What is the syntax. > >> I want to extend Activity as well as Application. Wont this create > >> problems in the manifest file? > >> Activity because, I need to do a couple of things during the > >> onCreate() [binding a service]and Application, because I am creating > >> objects of another class [service class]which needs to be accessible > >> throughout my application. > > >> Thanks, > >> Priyank > > >> -- > >> 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<android-developers%2bunsubscr...@googlegroups.com> > >> For more options, visit this group at > >>http://groups.google.com/group/android-developers?hl=en > > > -- > > Shane Isbell (Founder of ZappMarket) > >http://apps.facebook.com/zappmarket/ > > > -- > > 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<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en -- 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