package com.pas.camera;import java.io.File;import java.net.URI;import java.net.URISyntaxException;import android.net.Uri;import android.os.Bundle;import android.os.Environment;import android.provider.MediaStore;import android.app.Activity;import android.content.Intent;import android.graphics.Bitmap;import android.view.Menu;import android.view.View;import android.widget.ImageView;public class MainActivity extends Activity { private ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.iv); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public void click(View v) { Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.addCategory(Intent.CATEGORY_DEFAULT); File file = new File(Environment.getExternalStorageDirectory() + "/hahhaha.jpg"); // intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); startActivityForResult(intent, 0); } public void record(View v) { Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE); intent.addCategory(Intent.CATEGORY_DEFAULT); File file = new File(Environment.getExternalStorageDirectory() + "/hahhaha.3gp"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); startActivityForResult(intent, 0); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { if (data != null) { Bundle bundle = data.getExtras(); if (bundle != null) { Bitmap img = bundle.getParcelable("data"); if (img != null) { iv.setImageBitmap(img); } } } } else if (requestCode == 1) { } super.onActivityResult(requestCode, resultCode, data); }}