Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9012793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:05:46+00:00 2026-06-16T03:05:46+00:00

this is my source code which give two option when click on browse button

  • 0

this is my source code which give two option when click on browse button take picture from gallery or by take using camera i want to create new folder called”myfolder” and allpicture which i capture by camera is save on that folder not mobile default gallery folder how i do that
??

import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

public class AddEditCountry extends Activity {
 private long rowID; 
 private EditText nameEt;
 private EditText capEt;
 private EditText codeEt;
 private EditText Donedate;
 private EditText Notes;
 private EditText Person;
 private  ImageView imageView1;
public  static Bitmap yourSelectedImage = null;
public static byte[] blob = null;
private final int CAMERA_PICTURE = 1;
private final int GALLERY_PICTURE = 2;
private Intent pictureActionIntent = null;
//public static        byte[] blob = new byte[2048];

   @Override
   public void onCreate(Bundle savedInstanceState) 
   {
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.add_country);

      nameEt = (EditText) findViewById(R.id.Address);
      capEt = (EditText) findViewById(R.id.Stage);
      codeEt = (EditText) findViewById(R.id.Dueby);

      Donedate = (EditText) findViewById(R.id.Donedate);

      Notes = (EditText) findViewById(R.id.Notes);
      Person = (EditText) findViewById(R.id.Person);

      imageView1 = (ImageView) findViewById(R.id.imageView1);
      Button Browse = (Button) findViewById(R.id.Browse);
      Browse.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v) 
            {               
        //      Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        //      intent.setType("image/*");
         //     startActivityForResult(intent, 0);

                startDialog();
            }
        });        

      Bundle extras = getIntent().getExtras(); 

      if (extras != null)
      {
         rowID = extras.getLong("row_id");
         nameEt.setText(extras.getString("name"));  
         capEt.setText(extras.getString("cap"));  
         codeEt.setText(extras.getString("code"));  
         Donedate.setText(extras.getString("Location"));  
         Notes.setText(extras.getString("Notes")); 
         Person.setText(extras.getString("Person")); 
         }

      Button saveButton =(Button) findViewById(R.id.saveBtn);
      saveButton.setOnClickListener(new OnClickListener() {

          public void onClick(View v) 
          {
             if (nameEt.getText().length() != 0)
             {
                AsyncTask<Object, Object, Object> saveContactTask = 
                   new AsyncTask<Object, Object, Object>() 
                   {
                      @Override
                      protected Object doInBackground(Object... params) 
                      {
                         saveContact();
                         return null;
                      }

                      @Override
                      protected void onPostExecute(Object result) 
                      {
                         finish();
                      }
                   }; 

                saveContactTask.execute((Object[]) null); 
             }

             else
             {
                AlertDialog.Builder alert = new  
 AlertDialog.Builder(AddEditCountry.this);
                alert.setTitle(R.string.errorTitle); 
                alert.setMessage(R.string.errorMessage);
                alert.setPositiveButton(R.string.errorButton, null); 
                alert.show();
             }
          } 
     });
   }

   private void saveContact() 
   {

//     byte[] blob = new byte[2048];

       ByteArrayOutputStream outStr = new ByteArrayOutputStream();
       yourSelectedImage.compress(CompressFormat.JPEG, 100, outStr);
        blob = outStr.toByteArray();

      DatabaseConnector dbConnector = new DatabaseConnector(this);

      if (getIntent().getExtras() == null)
      {
          dbConnector.insertContact(nameEt.getText().toString(),
                  capEt.getText().toString(),
                  codeEt.getText().toString(),
                  Donedate.getText().toString(),
                  Notes.getText().toString(),
                  Person.getText().toString()
                  ,blob
                  );
      }
      else
      {
         dbConnector.updateContact(rowID,
            nameEt.getText().toString(),
            capEt.getText().toString(), 
            codeEt.getText().toString(), 
            Donedate.getText().toString(),
         Notes.getText().toString(),
          Person.getText().toString()
          , blob
         );
      }
   }

   @Override
   protected void onActivityResult(int requestCode, int resultCode, Intent  
    imageReturnedIntent) {
       super.onActivityResult(requestCode, resultCode, imageReturnedIntent);

       if (requestCode == GALLERY_PICTURE) {
            Uri uri = imageReturnedIntent.getData();
            if (uri != null) {
                // User had pick an image.
                Cursor cursor = getContentResolver().query(uri, new String[]  
     {  android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null);
                cursor.moveToFirst();
                final String imageFilePath = cursor.getString(0);
                File photos = new File(imageFilePath);
                yourSelectedImage = decodeFile(photos);
                yourSelectedImage =  
    Bitmap.createScaledBitmap(yourSelectedImage, 150, 150, true);
                imageView1.setImageBitmap(yourSelectedImage);
                cursor.close();
            }
            else {
                Toast toast = Toast.makeText(this, "No Image is selected.",  
   Toast.LENGTH_LONG);
                toast.show();
            }
        }
        else if (requestCode == CAMERA_PICTURE) {
            if (imageReturnedIntent.getExtras() != null) {
                // here is the image from camera
                yourSelectedImage = (Bitmap)  
  imageReturnedIntent.getExtras().get("data");
                imageView1.setImageBitmap(yourSelectedImage);
            }
        }
    }
   private Bitmap decodeFile(File f) {
        try {
            // decode image size
            BitmapFactory.Options o = new BitmapFactory.Options();
            o.inJustDecodeBounds = true;
            BitmapFactory.decodeStream(new FileInputStream(f), null, o);

            // Find the correct scale value. It should be the power of 2.
            final int REQUIRED_SIZE = 70;
            int width_tmp = o.outWidth, height_tmp = o.outHeight;
            int scale = 1;
            while (true) {
                if (width_tmp / 2 < REQUIRED_SIZE || height_tmp / 2 < 
 REQUIRED_SIZE)
                    break;
                width_tmp /= 2;
                height_tmp /= 2;
                scale++;
            }

            // decode with inSampleSize
            BitmapFactory.Options o2 = new BitmapFactory.Options();
            o2.inSampleSize = scale;
            return BitmapFactory.decodeStream(new FileInputStream(f), null,  
   o2);
        }
        catch (FileNotFoundException e) {
        }
        return null;
    }

    private void startDialog() {
        AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
        myAlertDialog.setTitle("Upload Pictures Option");
        myAlertDialog.setMessage("How do you want to set your picture?");

        myAlertDialog.setPositiveButton("Gallery", new 
  DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                pictureActionIntent = new Intent(Intent.ACTION_GET_CONTENT,  
  null);
                pictureActionIntent.setType("image/*");
                pictureActionIntent.putExtra("return-data", true);
                startActivityForResult(pictureActionIntent, GALLERY_PICTURE);
            }
        });

        myAlertDialog.setNegativeButton("Camera", new  
  DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                pictureActionIntent = new  
  Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(pictureActionIntent, CAMERA_PICTURE);
            }
        });
        myAlertDialog.show();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:05:47+00:00Added an answer on June 16, 2026 at 3:05 am

    Try this ::

     private void SelectPhotoFromCamera() 
        {
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File file = new File(Environment.getExternalStorageDirectory(),
                    "/DCIM" + ".jpg");
    
               if(file.isDirectory()) 
               {
                     //DO SOMETHING
               }                   
               else
               {
                      //DO SOMETHING
               }   
            outputFileUri = Uri.fromFile(file);
    
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, SELECT_PICTURE_CAMERA);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a source directory which uses makefile to compile the code. This makefile/configure
I have this source code from 2001 that I would like to compile. It
I am using vala. This is the source code that gives that compile time
This is heavily trimmed down source code from a webpage I'm working on right
I have downloaded the source code and using this logview to view log4net logs.
So this source code comes free from this website. http://math.hws.edu/javamath/basic_applets/SliderGraph.html It seems to be
I have this source code: idx=0 b=plt.psd(dOD[:,idx],Fs=self.fs,NFFT=512) B=np.zeros((2*len(self.Chan),len(b[0]))) B[idx,:]=20*log10(b[0]) c=plt.psd(dOD_filt[:,idx],Fs=self.fs,NFFT=512) C=np.zeros((2*len(self.Chan),len(b[0]))) C[idx,:]=20*log10(c[0]) for idx
I'm trying include this barcode source code Stefanhafeneger - Barcode github.com to my project
I'm new in ASP development. This is my source code : ident = request.Form(ident)
This is the complete source code: http://www.sendspace.com/file/lwxpyf I have a problem with a JSF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.