Hi,

You don't need to package everything as an activity. You can put the
common code in a global class and make all its members public. You
could even make everything a static field and it would be all exposed
to anyone who wanted to call it.

No need to get all fancy.

-niko

On Oct 7, 8:00 pm, amiz <[email protected]> wrote:
> Mark,
>
> Before you suggested the utility class, I packaged the code in a jar
> which I added to the project.
>
> Are there any pro/cons for the utility class vs the jar? This will be
> used within one app and not across apps.
>
> Thanks
> A.
>
> On Oct 7, 10:41 am, "Mark Murphy" <[email protected]> wrote:
>
> > > I have an app with two activities.
>
> > > Both activities among other functions have to perform the same
> > > calculation on data, so each activity include the same code to perform
> > > the calculation.
>
> > > Is it possible to only have the similar code in a separate activity
> > > and be accessed by the other two activities instead of duplicating the
> > > code twice?
>
> > Create a utility class that both activities can use that has your
> > calculation code. Assuming the activities and the utility class are all in
> > the same application, you should encounter no problems.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > Android App Developer Books:http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to