編輯:高級開發
public class AndroCamera extends Activity {
private static final int IMAGE_CAPTURE = 0;
private Button startBtn;
private Uri imageUri;
private ImageView imageVIEw;
/** Called when the activity is first created.
* sets the content and gets the references to
* the basic widgets on the screen like
* {@code Button} or {@link ImageVIEw}
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentVIEw(R.layout.main);
imageView = (ImageView)findVIEwById(R.id.img);
startBtn = (Button) findVIEwById(R.id.startBtn);
startBtn.setOnClickListener(new VIEw.OnClickListener() {
public void onClick(VIEw v) {
startCamera();
}
});
}
public void startCamera() {
Log.d("ANDRO_CAMERA", "Starting camera on the phone...");
String fileName = "testphoto.jpg";
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
values.put(MediaStore.Images.Media.DESCRIPTION,
"Image capture by camera");
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
imageUri = getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, IMAGE_CAPTURE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == IMAGE_CAPTURE) {
if (resultCode == RESULT_OK){
Log.d("ANDRO_CAMERA","Picture taken!!!");
接上頁
imageVIEw.setImageURI(imageUri);
}
}
}
頁面文件:
< ?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"
>
< Button android:text="Start Camera"
android:id="@+id/startBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
< /Button>
< ImageVIEw android:id="@+id/img"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
< /ImageVIEw>
< /LinearLayout >
國外一家名為Phandroid的網站近日披露了android 3.0(Gingerbread)的一些細節。雖然新的系統仍在開發之中,不過我們仍然可以從曝光的一些細節中看
; > android Repository: + android SDK Tools, revision 9 + android SDK Platf
android DDMS將為IDE搭建起與測試終端的鏈接,它們應用各自獨立的端口監聽調試器的信息,android DDMS最大的特性就是可以實時監測到測試終端的連接情況
android模擬器的重點就是商業應用,Google采用了一些手法來繞過這問題,建築在android之上的硬件驅動和應用程序,要求開源社區為它做貢獻,卻又不願提供回報。