Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.eksell.eksell.eksell;
- import android.content.Intent;
- import android.graphics.Bitmap;
- import android.net.Uri;
- import android.provider.MediaStore;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.ImageView;
- import android.widget.Toast;
- public class CameraActivity extends AppCompatActivity {
- private static final int REQUEST_IMAGE_CAPTURE = 1;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_camera);
- Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
- startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == REQUEST_IMAGE_CAPTURE) {
- if (resultCode == RESULT_OK) {
- Bitmap photo = (Bitmap)data.getExtras().get("data");
- Bundle extras = data.getExtras();
- Bitmap imageBitmap = (Bitmap) extras.get("data");
- ImageView.setImageBitmap(imageBitmap);
- Intent intent = new Intent(this, SendActivity.class);
- intent.putExtra("NewImage", photo);
- startActivity(intent);
- finish();
- }
- else if (resultCode == RESULT_CANCELED) {
- Toast.makeText(this, "Image capture canceled", Toast.LENGTH_LONG).show();
- finish();
- } else {
- Toast.makeText(this, "Image capture failed", Toast.LENGTH_LONG).show();
- finish();
- }
- }
- }
- =
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement