Camera Intent : Camera « Hardware « Android






Camera Intent

   
package app.test;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;

public class Test extends Activity {
  final static int CAMERA_RESULT = 0;
  ImageView imv;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    startActivityForResult(i, CAMERA_RESULT);
  }

  protected void onActivityResult(int requestCode, int resultCode,
      Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (resultCode == RESULT_OK) {
      Bundle extras = intent.getExtras();
      Bitmap bmp = (Bitmap) extras.get("data");
      imv = (ImageView) findViewById(R.id.ReturnedImageView);
      imv.setImageBitmap(bmp);
    }
  }
}
//main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
  <ImageView 
     android:id="@+id/ReturnedImageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content">
  </ImageView>
</LinearLayout>

   
    
    
  








Related examples in the same category

1.Camera preview
2.Camera With Intent
3.Media Store Camera Intent
4.Using Timer to control Camera
5.Camera orientation
6.Camera Preview and Camera.getNumberOfCameras()
7.Take a snapshot
8.Take and preview Photo
9.A grid that displays a set of framed photos.