0

I have made an app uploading pictures to server.

I succeed in just accessing to my basic gallery app after clicking the button

but after going to my basic gallery app , I want to choose my pictures(more than one) and make my own button to control(uploading or sending) them.

In android instagram, it controls like it!

But when accessing gallery app, this activity is not made by me, so I don't know how to control to get and send data.

What I done (helped by stack overflow) so far is below:

 @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");

    startActivityForResult(Intent.createChooser(intent, "Intent.createChooser"),        SELECT_PICTURE);

}
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    Toast.makeText(this, "onActivityResult 실행", Toast.LENGTH_LONG).show();
      if (resultCode == RESULT_OK) {
            if (requestCode == SELECT_PICTURE) {
                Uri selectedImageUri = data.getData();
                selectedImagePath = getPath(selectedImageUri);
                System.out.println("Image Path : " + selectedImagePath);
                img.setImageURI(selectedImageUri);
            }
        }
}
   public String getPath(Uri uri) {
        String[] projection = { MediaStore.Images.Media.DATA };
        Cursor cursor = managedQuery(uri, projection, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        return cursor.getString(column_index);
    }

But this code works, after accessing gallery app, when I select pictures, app is gone!

ligi
  • 39,001
  • 44
  • 144
  • 244
LKM
  • 2,410
  • 9
  • 28
  • 53
  • and manageQuery(~) method is deprecated, so i found that i should use method query(~), at this method, there is a parameter ContentResolver. What content resolver should be there? – LKM Aug 21 '14 at 10:47

1 Answers1

0

create an array of string String[] imagUrls=new String[n] to add image urls every time and insted of img.setImageURI(selectedImageUri); do like imageUrls[0]=selectedImageUri,imageUrls[0]=selectedImageUri ... and finally upload all images from the array.

NavinRaj Pandey
  • 1,674
  • 2
  • 26
  • 40
  • That is not a core thing – LKM Aug 22 '14 at 01:32
  • so you want to select more than one image from gallery right? – NavinRaj Pandey Aug 22 '14 at 03:08
  • for multiple selection http://stackoverflow.com/questions/19585815/select-multiple-images-from-android-gallery here is something useful – NavinRaj Pandey Aug 22 '14 at 04:26
  • Hmm actually whether it is one or more than one is not important, that is the next step, what i confront is after accessing the gallery, how to control gallery app activity! ㅜㅜ – LKM Aug 22 '14 at 05:33
  • looks like you need a custom gallary app activity this link may help you http://androidbite.blogspot.com/2012/09/android-custom-gallery-application.html – NavinRaj Pandey Aug 22 '14 at 05:50
  • I consider that too. but IN instagram app,when i upload my pictures it works by gallery app ... so i thought there is a way to do... – LKM Aug 22 '14 at 05:56
  • and when i select a picture app is gone! any way very very appreciate your help thank you NavinRaj Pandey! – LKM Aug 22 '14 at 05:57