I am using this code but my onActivityResult never gets called. I used to make the request without passing the extra intent to save the image to an SD card and that worked f
I use something like this and it works fine:
public class MainActivity extends Activity implements OnClickListener {
Button btnTackPic;
Bitmap bitMap;
static int TAKE_PICTURE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Setup camera ready for picture clicking
// add onclick listener to the button
btnTackPic.setOnClickListener(this);
}
// Take pic
@Override
public void onClick(View view) {
// create intent with ACTION_IMAGE_CAPTURE action
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// start camera activity
startActivityForResult(intent, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == TAKE_PICTURE && resultCode== RESULT_OK && intent != null){
// get bundle
Bundle extras = intent.getExtras();
// get bitmap
bitMap = (Bitmap) extras.get("data");
}
}
}