package com.example.cameratest;
// This project is adopted from https://eclass.srv.ualberta.ca/mod/resource/view.php?id=1136415
import java.io.File;

import com.example.cameratest.R;

import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends Activity {

    Uri imageFileUri;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        ImageButton button = (ImageButton) findViewById(R.id.TakeAPhoto);
        OnClickListener listener = new OnClickListener() {
            public void onClick(View v){
                takeAPhoto();
            }
        };
        button.setOnClickListener(listener);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
    private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 12345;
    
    //This method creates an intent. 
    //It is told that we need camera action, and the results should be saved in a location that is sent to the intent.
    public void takeAPhoto() {
		
    	String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyCameraTest";
		File folder = new File(path);
		
		if (!folder.exists()){
			folder.mkdir();
		}
			
		String imagePathAndFileName = path + File.separator + 
				String.valueOf(System.currentTimeMillis()) + ".jpg" ;
		
		File imageFile = new File(imagePathAndFileName);
		imageFileUri = Uri.fromFile(imageFile);
		
		Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
		intent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);
		startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    }
    
    //This method is run after returning back from camera activity:
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		
    	if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE){
			TextView tv = (TextView)findViewById(R.id.status);
			
			if (resultCode == RESULT_OK){
				tv.setText("Photo completed!");
				ImageButton ib = (ImageButton)findViewById(R.id.TakeAPhoto);
				ib.setImageDrawable(
					Drawable.createFromPath(imageFileUri.getPath()));
			}
			else
				if (resultCode == RESULT_CANCELED){
					tv.setText("Photo was canceled!");
				}
				else
					tv.setText("What happened?!!");
		}
    }
}

@@ -1247,87 +1247,9 @@
    %0A
-    private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 12345;%0A    
 %0A
+
     
@@ -1840,197 +1840,105 @@
 %09%0A%09%09
-Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);%0A%09%09intent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);%0A%09%09startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
+//TODO: Add your code here ...%0A%09%09//TODO: Add your code here ...%0A%09%09//TODO: Add your code here ...%0A
 %0A   
@@ -2128,43 +2128,13 @@
  == 
-CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE
+12345
 )%7B%0A%09
@@ -2230,185 +2230,140 @@
 %0A%09%09%09
-%09tv.setText(%22Photo completed!%22);%0A%09%09%09%09ImageButton ib = (ImageButton)findViewById(R.id.TakeAPhoto);%0A%09%09%09%09ib.setImageDrawable(%0A%09%09%09%09%09Drawable.createFromPath(imageFileUri.getPath()));
+//TODO: Add your code here ...%0A%09%09%09//TODO: Add your code here ...%0A%09%09%09//TODO: Add your code here ...%0A%09%09%09//TODO: Add your code here ...
 %0A%09%09%09

Update MainActivity.java