Android Kamera Kullanımı

package com.hero.camera;

import java.io.ByteArrayOutputStream;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MyCameraActivity extends Activity {
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
//resim cek butonuna basilinca kameranin acilmasini saglar
photoButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}

//kamera ile resim cekildikten sonra bitti butonuna bastiktan sonra resmin imageview de gosterilmesini saglar
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
}
}

AndroidManifest.xml dosyasında application tagından önce

eklenmesi gerekmektedir.

“Android Kamera Kullanımı” üzerine 1 yorum.

  1. I think this is one of the most significant information for me. And i’m glad reading your article. But should remark on some general things, The web site style is wonderful, the articles is really excellent D. Good job, cheers akefcdaaekgd

Bir cevap yazın