Advertisement
Guest User

Untitled

a guest
May 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import android.content.Intent;
  2. import android.graphics.Bitmap;
  3. import android.media.Image;
  4. import android.provider.MediaStore;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.ImageView;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11.  
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_main);
  16. }
  17.  
  18. public void tomarFoto(View view)
  19. {
  20. Intent llamdaCamara = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  21. startActivityForResult(llamdaCamara, 0);
  22. }
  23. @Override
  24. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  25. // Check which request we're responding to
  26. ImageView fotopreview = findViewById(R.id.preview);
  27.  
  28. //if (requestCode == PICK_CONTACT_REQUEST) {
  29. // Make sure the request was successful
  30. if (resultCode == RESULT_OK)
  31. {
  32. Bundle extra = data.getExtras();
  33. Bitmap imageBitmap = (Bitmap) extra.get("data");
  34. fotopreview.setImageBitmap(imageBitmap);
  35.  
  36. // The user picked a contact.
  37. // The Intent's data Uri identifies which contact was selected.
  38.  
  39. // Do something with the contact here (bigger example below)
  40. }
  41. //}
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement