Joe Ba Joe Ba -4 years ago 115
Android Question

Number of occurrence of a face between an interval of [40 cm; 80cm]

I tried to increase++ a number (i) each time the distance between the camera and my face is between 40 cm and 80 cm. Unfortunately when it happen the textview shows (The number of occurrence is: 50). Help me please

public void update(final Messsage msg) {
for(int i = 0; i < 50; ++i) {
if (msg.getDistanceToFace() > 40 && msg.getDistanceToFace() < 80) {
textView.setText("The number of occurrence is: " + i);

Answer Source

you should probably add a break after you set the text, the way you coded it will set a text for all the iteration of i but you will only see the last one (50)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download