Hey folks,
being new to Java, I am trying to analyse a picture, which was taken by the smartphone's camera. (This works so far). Now I want to trigger the analysing method with the counter button.
Whatever method I try to trigger, the app will stop.
I will be happy for advice.
Cheers
Felix

package de.felix_h.mcounter;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.provider.MediaStore;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.content.pm.PackageInfo;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Environment;






public class MainActivity extends ActionBarActivity {

static final int REQUEST_IMAGE_CAPTURE = 1;
ImageView sweetimage;

//amount of mm
int redmm, greenmm;
Bitmap photo;

@Override
protected void onCreate(Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
setContentView(R.layout.activity_main);

Button picbutton = (Button) findViewById(R.id.picbutton);
Button counter = (Button) findViewById(R.id.counter);
sweetimage = (ImageView) findViewById(R.id.sweetimage);


//Disable the button if the user has no camera
if (!hasCamera())
picbutton.setEnabled(false);
}

//Check if the user has a camera
private boolean hasCamera() {
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
}

//Launching the camera
public void launchCamera(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//Take a picture and pass results along to onActivityResult
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}

//If you want to return the image taken
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
//Get the photo
Bundle extras = data.getExtras();
Bitmap photo = (Bitmap) extras.get("data");
sweetimage.setImageBitmap(photo);
}
}

//Readout the image information
public void countmm(Bitmap original) {

//Counting variable
int redpixel = 0;
int greenpixel = 0;
int bluepixel = 0;

int R, G, B;
int pixelColor;
int height = original.getHeight();
int width = original.getHeight();

for (
int y = 0;
y < height; y++)

{
for (int x = 0; x < width; x++) {
pixelColor = original.getPixel(x, y);
R = Color.red(pixelColor);
G = Color.green(pixelColor);
B = Color.blue(pixelColor);

if (R + G + B > 600) {
break;
} else if (R > G && R > B) {
redpixel++;
break;
} else if (G > R && G > B) {
greenpixel++;
break;
} else if (B > R && B > G) {
bluepixel++;
break;
}
}
}


redmm = redpixel / bluepixel;
greenmm = greenpixel / bluepixel;
}

}