I have this code right here:
public class pantalla8 extends Activity {
protected static final int CAMERA_REQUEST = 0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
final Button logout = (Button) findViewById(R.id.boton13);
logout.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
finish();
}
});
final Button camera = (Button) findViewById(R.id.boton12);
camera.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
Intent cameraIntent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
}
}
}
Which invokes camara's service.
With this, I can take pictures, save them and return to my app without problems. But if I don't want to save the picture, otherwise, discard it; an error occurs and Android forces the application to close.
My question is, what's missing in my code to handle that event? I mean, if the user discard a picture, the camera should be called once again.
Plus, when the user saves a picture; how do I relate those pics with my app? I think I should use a SQLite table, but I'm not sure how to do it, because, later those pictures must be sent to a server.
I would appreciate any kind of help! Thanks in advance!