Using Intent of "MediaStore.ACTION_IMAGE_CAPTURE", we can request Android build-in Camera App or other Service Provider to take picture.
main.xml
main.xml
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
android:orientation
=
"vertical"
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
>
<
TextView
android:layout_width
=
"fill_parent"
android:layout_height
=
"wrap_content"
android:text
=
"@string/hello"
/>
<
Button
android:id
=
"@+id/captureimage"
android:layout_width
=
"fill_parent"
android:layout_height
=
"wrap_content"
android:text
=
"Call for ACTION_IMAGE_CAPTURE"
/>
<
ImageView
android:id
=
"@+id/imagecaptured"
android:layout_width
=
"wrap_content"
android:layout_height
=
"wrap_content"
/>
</
LinearLayout
>
AndroidImageCapture.java
package
com.AndroidImageCapture;
import
android.app.Activity;
import
android.content.Intent;
import
android.graphics.Bitmap;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Button;
import
android.widget.ImageView;
public
class
AndroidImageCapture
extends
Activity {
ImageView imageiewImageCaptured;
/** Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonImageCapture = (Button)findViewById(R.id.captureimage);
imageiewImageCaptured = (ImageView)findViewById(R.id.imagecaptured);
buttonImageCapture.setOnClickListener(buttonImageCaptureOnClickListener);
}
Button.OnClickListener buttonImageCaptureOnClickListener
=
new
Button.OnClickListener(){
@Override
public
void
onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent =
new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,
0
);
}};
@Override
protected
void
onActivityResult(
int
requestCode,
int
resultCode, Intent data) {
// TODO Auto-generated method stub
super
.onActivityResult(requestCode, resultCode, data);
if
(resultCode == RESULT_OK)
{
Bundle extras = data.getExtras();
Bitmap bmp = (Bitmap) extras.get(
"data"
);
imageiewImageCaptured.setImageBitmap(bmp);
}
}
}
Cheers Guys!!!!!!!!!!!
I love your comment here...
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :