0

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

Reza
  • 23
  • 5
  • If you want help you should at least demonstrate what you've tried and where you're stuck. Start with a basic activity that asks for camera permission and can take a photo. Start here https://developer.android.com/training/camera/photobasics – spartygw Aug 25 '21 at 18:22
  • I recommend that you [reconsider your JDBC plan](https://stackoverflow.com/q/15853367/115145). – CommonsWare Aug 25 '21 at 18:28
  • `// I can take pacture by camera` No you cant as you only get a thumbnail of the picture. – blackapps Aug 25 '21 at 19:34
  • In theory It may work with some help.. But there are a few problems to mention. 1) It's not safe and not usefull to use JDBC on android apps. Solution: You should be using a web service , an api to communicate with SQL server. 2) You can not store .PNG on SQL Table you should convert your .PNG files to a BLOB object and send to Database THROUGH the API – Mahir Özdin Aug 25 '21 at 21:37
  • do you have any sample project code? – Reza Aug 26 '21 at 13:04

0 Answers0