You're forgetting that it facilitates unit testing. On Jan 5, 1:26 am, Kostya Vasilyev <[email protected]> wrote: > 05.01.2011 2:01, Emre A. Yavuz О©╫О©╫О©╫О©╫О©╫: > > > Thanks Kostya, > > > I've actually been aware of using a callback interface reference to > > solve this problem, but considering its size and importance (in what > > I've been working on) > > Size and importance? > > > I just wanted to find out whether there's a simpler way to do it or not. > > A Java interface seems like a pretty simple way to me. > > In fact, using interfaces to connect pieces of code provides some > important benefits: > > - It reduces coupling between classes, separating behavior and > implementation dependencies; > > - It creates a well-defined contract for the class using the interface; > > - Provides a way to "call up" in a layered system; > > - Related to the above, makes it possible to compile layers as separate > units. > > and probably some others that I'm forgetting right now. > > -- Kostya > > > > > > > > > > > Cheers, > > > Emre > > > ------------------------------------------------------------------------ > > Date: Tue, 4 Jan 2011 17:03:53 +0300 > > Subject: Re: [android-developers] Calling a non-static method in an > > Activity class from a non-Activity class ? > > From: [email protected] > > To: [email protected] > > > You can override onPause and onResume in your activity and keep track > > of its screen time. > > Another, cleaner way is to pass a callback interface reference from > > your activity to "the other" class instance. > > -- > > Kostya Vasilyev --http://kmansoft.wordpress.com > > 04.01.2011 16:49 О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫ "Emre A. Yavuz" > > <[email protected] > > <mailto:[email protected]>> О©╫О©╫О©╫О©╫О©╫О©╫О©╫: > > > > Hi, > > > > This question might actually have been brought to developer's > > attention here on the list before, yet I wasn't able to find a > > solution after a brief search on the net. > > > > I have a method in one of my Activity classes which I would like to > > call from a non-Activity class when the Activity class that the method > > is a member of is active and running (e.g. in my case the Activity > > class that I am refering to is in fact a ListActivity class and thus > > it displays a list of items on the screen when it is running) The > > problem arises when the non-Activity class, which has a Broadcast > > Receiver, needs to call this method to update the list. > > > > Here are my contraints: > > > > - I can't move the method to a static class > > > > - I can make neither the Activity class nor the method just by > > itself static > > > > Is there any way to retrieve the "context" for the Activity that is > > currently running ? Maybe I am missing a straight forward solution > > here. Any suggestions on how to proceed ? > > > > Thanks in advance, > > > > Emre > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > > [email protected] > > <mailto:[email protected]> > > > To unsubscribe from this group, send email to > > > [email protected] > > <mailto:android-developers%[email protected]> > > > 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 [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > 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 [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget > --http://kmansoft.wordpress.com
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

