Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:23:02+00:00 2026-05-25T14:23:02+00:00

I am fooling around with some basic programming in Android using Eclipse. I’m currently

  • 0

I am fooling around with some basic programming in Android using Eclipse. I’m currently looking through a book and playing with some sample code that is written in the book.

I have noticed that in this particular book, all of the examples so far take pace in Main-Activity. I don’t believe this to be very good Object Oriented programming practice as I am from a traditional Java background.

Is this the common practice for mobile platforms? Shouldn’t classes all be contained in their own files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:23:03+00:00Added an answer on May 25, 2026 at 2:23 pm

    Shouldn’t classes all be contained in their own files?

    Not necessarily as an Android Activity is a ‘special case’ class. If you haven’t done already, I’d recommend you read Application Fundamentals and in particular the section on ‘Activities’ under Application components…

    An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. Although the activities work together to form a cohesive user experience in the email application, each one is independent of the others. As such, a different application can start any one of these activities (if the email application allows it). For example, a camera application can start the activity in the email application that composes new mail, in order for the user to share a picture.

    Note the section of text that I’ve highlighted in bold. The point is that an Activity in itself is not the complete app and if allowed, any third-party app can potentially invoke an Activity in one of your apps. As such, it is common to make an Activity as self-contained as possible. One particular example is the use of something like an AsyncTask which provides methods to execute a background thread as well as manipulate the UI – nesting a private class which extends AsyncTask is quite common and simplifies code. Nesting classes which extend BroadcastReceiver is also common for the same reason.

    That said, there is nothing wrong with using separate Java class files for POJO helper classes, for example, it just comes down to how complex your app is but it can mean taking special consideration of how certain Android classes work – the AsyncTask class being one in particular if defined in a separate class file, try it and you’ll see what I mean. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was fooling around with some functional programming when I came across the need
I was just fooling around with some Domain Specific Language designs for a new
I'm fooling around with Yahoo! pipes and I'm hitting a wall with some regular
I've been fooling around with malloc, realloc and free in order to write some
I'm currently fooling around with AJAX. Right now, I created a Markdown previewer that
I'm recently fooling around with some ajax polling techniques. However, it seems like I
I'm just fooling around with the subsonic ORM for the first time. I'm using
I referenced the code from Android Developer. After compliling the code and fooling around
I'm fooling around with WCF, and would like to see how many messages I
I recently installed the BIRT all in one developer program and started fooling around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.