Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

JavabeginnermobileAI generated

Android BMI & Calorie Calculator App

Build an Android app in Java that calculates your body mass index (BMI) and estimates how many calories you need per day, from your height, weight, age, sex and activity level. The screen is designed with XML layouts, the Activity's Java code reads the inputs, validates them, applies the standard formulas (BMI, and the Mifflin-St Jeor equation for calories) and shows the results with a colored category. Values are kept when the phone is rotated. It's a good first Android app: you'll learn Android Studio, XML layouts and views, connecting views to Java code, input validation, the Activity lifecycle and saving state, and testing.

Estimate
~7.5h
Steps
6
Completed by
0
Proposed by
codeseed.app

Android SDK · Java · XML layouts

Project roadmap

  1. 01

    Design the input form

    ~1.5h

    Create an Android Studio project with an Empty Views Activity in Java. In activity_main.xml, build a form in a ScrollView: height (cm) and weight (kg) fields with number keyboards (inputType), an age field, a RadioGroup for sex, a Spinner for activity level (sedentary to very active), and a Calculate button, with labels and spacing. Done when: the form displays correctly on the emulator.

  2. 02

    Connect the Activity

    ~1h

    In MainActivity.java, find the views with findViewById (or view binding), set up the Spinner with an ArrayAdapter from a string array resource, and handle the button click by reading the values. Done when: pressing Calculate reads the values (shown in a Toast or log for now).

  3. 03

    Implement the formulas

    ~1h

    Write a separate plain Java class with the calculations: BMI (weight divided by height in meters squared), its category (underweight below 18.5, normal up to 24.9, overweight up to 29.9, obese from 30), the basal metabolic rate with the Mifflin-St Jeor equation, and daily calories by multiplying it by the activity factor. Done when: the methods return correct results for examples calculated by hand.

  4. 04

    Show the results

    ~1h

    Show the BMI rounded to one decimal with its category in a color (blue, green, orange or red), and the estimated daily calories, plus a short note that these are rough estimates and not medical advice. Use string resources for all text. Done when: results display clearly with the right color.

  5. 05

    Validate input and handle rotation

    ~1.5h

    Validate every field (required, a number, and within a sensible range, such as 50 to 250 cm, 20 to 300 kg and 15 to 100 years), showing errors on the fields with setError. Keep the entered values and the results when the phone is rotated, by saving them in onSaveInstanceState and restoring them (or with a ViewModel). Done when: invalid values show errors, and rotating keeps everything.

  6. 06

    Test it

    ~1.5h

    Write JUnit tests for the calculations class (each BMI category boundary and the calorie formula for both sexes), and an Espresso test that fills the form, taps Calculate and checks the result text. Done when: all tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~7.5h · 6 steps

Tech stack

Android SDKJavaXML layouts