Posts Tagged ‘shapeup’

How to program a simple andriod application that converts kilo calories to kilo joules

April 25, 2012

I decided to learn some android programming and therefore I decided to code a small android application which converts a given amount of energy from kilocalories to kilojoules and from kilocalories to kilojoules. I chose to code such an app since I’m trying to get fit for the summer and record what I eat into shapeup club. I usually think about calorie intake in terms of kilojoules but the shapeub club only accepts kilocalories. So therefore I figure out how many kilojoules I’ve taken in and use this app to find out how man kilocalories I should add in the shapeup club app. The application itself is quite simple it has to buttons which starts two functions that perform conversions. The result of a function calls is recorded on one of the programs to result fields. The result field is a simple textview control which is updated with the settext() method.

My andriod app

My andriod app

The source code is as follows:
package com.example.test5;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

public class Test5Activity extends Activity {
/** Called when the activity is first created. */
Button btnCalcKj=null;
Button btnCalcKcal=null;
EditText edTxtNumKcal=null;
EditText edTxtNumKj=null;
TextView tvCompKj=null;
TextView tvCompKcal=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnCalcKj=(Button)findViewById(R.id.btnCalcKj);
btnCalcKcal=(Button)findViewById(R.id.btnCalcKcal);
edTxtNumKcal=(EditText)findViewById(R.id.edTxtNumKcal);
edTxtNumKj=(EditText)findViewById(R.id.edTxtNumKj);
tvCompKcal=(TextView)findViewById(R.id.tvCompKcal);
tvCompKj=(TextView)findViewById(R.id.tvCompKj);
tvCompKcal.setText(“”);
tvCompKj.setText(“”);
btnCalcKcal.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try{
// Perform action on click
double numKcal=calcNumKcal(Double.parseDouble(“”+edTxtNumKj.getText()) );
tvCompKcal.setText(“”+numKcal);
tvCompKj.setText(“”);
edTxtNumKcal.setText(“”);
edTxtNumKj.setText(“”);
}
catch(Exception e){
}
}
});
btnCalcKj.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
try{
double numKj=calcNumKj(Double.parseDouble(“”+edTxtNumKcal.getText()) );
tvCompKj.setText(“”+numKj);
tvCompKcal.setText(“”);
edTxtNumKj.setText(“”);
edTxtNumKcal.setText(“”);}
catch(Exception e){
}
}
});
}
private  double calcNumKj(double Kcal){
return Kcal*4.12;
}

private double calcNumKcal(double Kj){
return Kj/4.12;
}
}

You can also download the source code by clicking the link below. Get this app running by creating a new android 2.3.3 project in Eclipse named “Test5”. Thereafter you paste all of the code above into the file called “Test5Activity”.

Source code

Advertisements

ShapeUp Club and BodyMonitor, two andriod apps to help you to stay fit!

March 25, 2012

I’ve found two android apps which help you stay fit. The first is called ShapeUp Club and the second is called Body Monitor.
Shape Up Club is a calorie counter which helps you keep track of how many calories you take in and consume everyday. The application has
a database of more than four hundred thousand food items, so you can find a lot of thing which you might eat in this database. You can enter
your intake and consumption of calories within the application. The consumption of calories is calculated by entering what type of workout you have done and for
how many minutes or hours you worked out. How many calories you consumed during that workout, It’s especially suitable for smartphones since you can find different kinds of food
by pointing and touching instead of entering data with the touch keyboard. It can also tack your weight, body fat and measurements. The application can
give you a summary of the number of calories you’ve consumed during the last 30 days. This summary contains an average amount of calories which you’ve consumed
during each week. The software can graph your measurements, your weight and body fat. The graphs are very informative and easy to read.

The startup screen of shapeub club

The startup screen of ShapeUp Club

Body monitor is an application to monitor your body fat, weights and measurements. One of the best features of this software is that it graphs your weight, body fat or measurements
during the last 30 days, You can check the graph to see if the trend i it’s going up or down. The software has a calendar view where you can enter
your weight, height, body fat and so on for each day. It let’s you track the fitness of several users so your entire family can use it! Graphs can be exported to
and SD card and weight and other fitness can also be exported to your SD card in a format that is readable by common spreadsheet applications such as Excel.*

Body Monitor Calender Screen

Body Monitor Calender Screen

Body Monitor Graph Screen

Body Monitor Graph Screen

 

Read other people’s blogs about on Technorati about: , , , , , , , ,

Läs även andra bloggares åsikter om: , , , , , ,

Technorati token: F6U8ZD2JJGDG


%d bloggers like this: