Jumat, 07 September 2012

Image Pickcer Android sourcode


Cara mengambil Gambar di Gallery Android Source Code














 public void munculkanGambar(){
         Intent i = new Intent(
                    Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            i.setType("image/*");
            startActivityForResult(i, RESULT_LOAD_IMAGE);
     }

protected void onActivityResult(int requestCode, final int resultCode, final Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
           
            if (resultCode == RESULT_OK ) {
                Uri selectedImage = data.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };

                cur= getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
               
                cur.moveToFirst();
           
               

                int columnIndex = cur.getColumnIndex(filePathColumn[0]);
                String picturePath = cur.getString(columnIndex);
                Gambar=picturePath;
                               
           
            //cur.requery();
             BitmapFactory.Options options = new BitmapFactory.Options();
               options.inSampleSize = 2;
               Bitmap bm = BitmapFactory.decodeFile(picturePath);
               wgambar.setImageBitmap(bm);
               cur.close();
            }
       
       
        }

web support  
www.klikcover.com

Tidak ada komentar:

Posting Komentar