I write this code ti take a picture and then send it to other activity. but every time I run it camera dosent start and only intent 2 in takephoto class start new activity. and if I remove this part camera start:
Intent intent2 = new Intent (welcom.this, MainActivity.class);
startActivity(intent2);
intent2.putExtra("mImageUri", imageUri);
the code:
public class welcom extends Activity{
private static final int TAKE_PICTURE = 1;
private Uri imageUri;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.welcom);
Button camera= (Button) findViewById(R.id.camera);
Button gallery= (Button) findViewById(R.id.gallery);
camera.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
takePhoto();
}
});
gallery.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
});
}
public void takePhoto() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
Intent intent2 = new Intent (welcom.this, MainActivity.class);
startActivity(intent2);
intent2.putExtra("mImageUri", imageUri);
}}