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

  • SEARCH
  • Home
  • 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 8338133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:29:58+00:00 2026-06-09T04:29:58+00:00

I was recently asked some questions in an interview about Android. I searched for

  • 0

I was recently asked some questions in an interview about Android. I searched for some of them but I couldn’t find the suitable resources and answers. So I wanted to share it with you here.

  1. What is the preferred layout to use in Android ( for Better memory consumption or so ) ?
    I didn’t have answer for that and the interviewer told me it is relative layout. Is this true ? any explanation for that ?

  2. Tell me some practices you do for better memory consumption ?
    I had a look here but it seems there are other stuff. because the interviewer mentioned some things related to static variables are better.

  3. If Android needs memory, will it kill a service or Activity ? a matter of priority issue. I also didn’t find any one discussing this. The interviewer said some thing about Service has high priority (??) than activity so the activity is the component which will be killed. Is this true ? any further resources or explanations ?

Kindly share any knowledge or resources you know about this issues.

  • 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-06-09T04:30:00+00:00Added an answer on June 9, 2026 at 4:30 am

    Answering one by one:

    Nr. 1

    Sounds wrong. It’s wrong to say that RelativeLayout is always faster than any other layout. What makes a layout “fast” or “slow” is how long it takes to calculate the positions and sizes for all it’s children. So when you’re only displaying 15 rows of TextView, one below the other, a LinearLayout would most certainly be faster (and less cumbersome to use).

    Generally, I would advice to use the layout that best suites your situation.

    Nr. 2

    Preferring static variables has the “advantage” that they are initialized (and therefor in memory) only once. But this is more of a design decision than a performance one.

    You should avoid huge nested collections in memory (such as List<List<HashMap<?,?>>), but this should really be common sense. The thing with object creation is, that if you create many objects and don’t keep any references to them, they’ll get garbage collected. This will add runtime-overhead to your application.

    Nr. 3

    This is both right and wrong. Services can be started with different priorities. But, before anything used by your application (be it a service or an activity) gets killed, backgrounded applications and their resources will be freed.

    For Services, the documentation gives multiple hints:

    The Android system will attempt to keep the process hosting a service
    around as long as the service has been started or has clients bound to
    it.
    When running low on memory and needing to kill existing processes,
    the priority of a process hosting the service will be the higher of
    the following possibilities
    : [Full List]

    On Activities, the following is listed:

    An activity has essentially four states:

    • If an activity in the foreground of the screen (at the top of the stack), it is active or running.

    • If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your
      activity), it is paused. A paused activity is completely alive (it
      maintains all state and member information and remains attached to the
      window manager), but can be killed by the system in extreme low memory
      situations.

    • If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however,
      it is no longer visible to the user so its window is hidden and it
      will often be killed by the system when memory is needed elsewhere.

    • If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing
      its process.
      When it is displayed again to the user, it must be
      completely restarted and restored to its previous state.

    So, for Activities, it depends on the current state how likely it is for it to be killed.

    Conclusion

    A quote on optimization by “M. A. Jackson”:

    We follow two rules in the matter of optimization:
    Rule 1: Don’t
    do it.
    Rule 2 (for experts only): Don’t do it yet – that is, not
    until you have a perfectly clear and unoptimized solution.

    Not using a particular platform feature because it is “too slow” is often a bad idea. Google and Oracle take great care that their standard libraries are as
    optimized as possible
    . Let the experts worry about things like this.

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

Sidebar

Related Questions

So I recently asked a question about memoization and got some great answers, and
Recently, I was asked to compile some of my Android projects, based on the
I recently asked a question about some problems I was having getting MIT Kerberos
I recently asked this question here and got some great answers! Custom SQL GROUP
I found similar questions asked here but there weren't answers to my satisfaction. So
I recently asked this question https://softwareengineering.stackexchange.com/questions/129076/go-instead-of-c-c-with-cgo and got some very interesting input. However there's
I recently asked about accessing data from SPSS and got some absolutely wonderful help
I recently asked a question about structs, and optimizing some overloaded operators. The original
I recently asked a question about functional programming, and received (good!) answers that prompted
Hello I recently asked some questions on linked lists in C. The link was

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.