Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Intent;
- import android.graphics.Bitmap;
- import android.media.Image;
- import android.provider.MediaStore;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.ImageView;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- }
- public void tomarFoto(View view)
- {
- Intent llamdaCamara = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- startActivityForResult(llamdaCamara, 0);
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- // Check which request we're responding to
- ImageView fotopreview = findViewById(R.id.preview);
- //if (requestCode == PICK_CONTACT_REQUEST) {
- // Make sure the request was successful
- if (resultCode == RESULT_OK)
- {
- Bundle extra = data.getExtras();
- Bitmap imageBitmap = (Bitmap) extra.get("data");
- fotopreview.setImageBitmap(imageBitmap);
- // The user picked a contact.
- // The Intent's data Uri identifies which contact was selected.
- // Do something with the contact here (bigger example below)
- }
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement