Pro22Activity.java
Note: Give permission in manifest file as "android.permission.CAMERA"
package ps.pro22;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
public class Pro22Activity extends Activity implements OnClickListener {
/**
* www.master-gtu.blogspot.com
* pankaj sharma(8460479175),
* chavda vijay(8460420769)
*/
ImageView img;
Button btcapture;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
img=(ImageView) findViewById(R.id.imageView1);
btcapture=(Button) findViewById(R.id.buttoncapture);
btcapture.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent myintent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(myintent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
Bitmap myimage=(Bitmap) data.getExtras().get("data");
img.setImageBitmap(myimage);
}
}
I want output
ReplyDelete