I want to take a photo by android camera and save in in memory and after resizing send to MSSQL server by JDBC method. anybody can help me with any answer code?
//capture picture from camera
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// capture picture
Intent camIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
try {
startActivityForResult(camIntent, CameraRequest);
} catch (ActivityNotFoundException e) {
Toast.makeText(InstallForm.this, "camera not found", Toast.LENGTH_SHORT).show();
}
}
});
// Checking camera availability
if (!isDeviceSupportCamera()) {
Toast.makeText(getApplicationContext(),
"Sorry! Your device doesn't support camera",
Toast.LENGTH_LONG).show();
// will close the app if the device does't have camera
finish();
}
//capture image
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
if (requestCode == CameraRequest) {
clear.setVisibility(View.VISIBLE);
imgView.setVisibility(View.VISIBLE);
uploadimage.setVisibility(View.VISIBLE);
resultPhoto = (Bitmap) Objects.requireNonNull(data.getExtras()).get("data");
imgView.setImageBitmap(resultPhoto);
filename.setText(" service Image " + number);
}
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imgView.setImageResource(0);
clear.setVisibility(View.GONE);
imgView.setVisibility(View.GONE);
uploadimage.setVisibility(View.GONE);
filename.setText("no image");
}
});
generateNewAttachmentList(newAttachmentList);
}catch(Exception e){
e.printStackTrace();
Log.d( "Exception : " , e.getMessage() );
}
}
private void generateNewAttachmentList(ArrayList<AttachmentListData> newAttachmentList) {
newAttachmentListView.setHasFixedSize(true);
LinearLayoutManager MyLayoutManager = new LinearLayoutManager(InstallForm.this);
MyLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
newAttachmentListView.setLayoutManager(MyLayoutManager);
attachmentListAdapter = new AttachmentListAdapter(newAttachmentList, InstallForm.this);
newAttachmentListView.setAdapter(attachmentListAdapter);
}
// I can take pacture by camera and show in image wiew and in continue I want to save my image in phone memory, then resize it and send to MSSQL server by jdbc.
any answer