1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ?xml version="1.0" encoding="utf-8"?> android:layout_width = "fill_parent" android:layout_height = "fill_parent" android:orientation = "vertical" > < TextView android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "Capture Image" /> < Button android:id = "@+id/btCamera_main" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "Take Picture" /> </ LinearLayout > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class CameraTestAppsActivity extends Activity { Button btCamera; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.main); btCamera=(Button)findViewById(R.id.btCamera_main); btCamera.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 0 ); } }); } @Override public void onActivityResult( int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == 0 ) { String result = data.toURI(); } } } |
1 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
1 | < uses-permission android:name = "android.permission.CAMERA" ></ uses-permission > |
I was recommended this website by my cousin. I'm not sure whether this
ReplyDeletepost is written by him as nobody else knpw such detailed about my trouble.
Yoou aree incredible! Thanks!
Feel free to visit my homepage would, ,