0
  • Initially i was using bitmap to handle image event

  • I can able to pass bitmap to activity and can load image also

  • But when i was testing i found in some device bitmap crash

  • What i have done

-- For image selection and passing :

private void selectImage() {
    final CharSequence[] items = {"Choose from Library"};
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Add Photo!");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int item) {
            /*if (items[item].equals("Take Photo")) {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, IntentConst.REQUEST_CAMERA);
            } else*/
            if (items[item].equals("Choose from Library")) {
                Intent intent = new Intent(
                        Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                intent.setType("image/*");
                startActivityForResult(
                        Intent.createChooser(intent, "Select File"),
                        IntentConst.SELECT_FILE);
            }
        }
    });
    builder.show();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == this.RESULT_OK) {

        if (requestCode == IntentConst.SELECT_FILE) {
            Uri selectedImageUri = data.getData();
            String[] projection = {MediaStore.MediaColumns.DATA};
            Cursor cursor = this.managedQuery(selectedImageUri,
                    projection, null, null, null);
            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
            cursor.moveToFirst();
            selectedImagePath = cursor.getString(column_index);

            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(selectedImagePath, options);
            final int REQUIRED_SIZE = 200;
            int scale = 1;
            while (options.outWidth / scale / 2 >= REQUIRED_SIZE
                    && options.outHeight / scale / 2 >= REQUIRED_SIZE)
                scale *= 2;
            options.inSampleSize = scale;
            options.inJustDecodeBounds = false;
            setimg = BitmapFactory.decodeFile(selectedImagePath, options);

            Log.e("image path",selectedImagePath);

            ivProImage.setImageBitmap(setimg);
        }

        if (requestCode == RESULT_SEND) {
            Intent intent = new Intent(getApplicationContext(), ActivityCardLogo1.class);
            startActivity(intent);
        }
    }
}

-- What i want is, send image string to next activity and load image with AQuery

tiger
  • 413
  • 1
  • 5
  • 18
  • send it as a base64 string by putExtra method in intent; get the same and load the image in the next activity – DJphy Mar 18 '16 at 13:10
  • can u show demo plz. – tiger Mar 18 '16 at 13:12
  • **1.** browse on how to convert image to base64; **2.** how to send pass string using intent to another activity **3.** get string from intent activity – DJphy Mar 18 '16 at 13:14
  • that should help; also; **4.** how to get bitmap of image using base64 string ; so that u can set it on a image view. – DJphy Mar 18 '16 at 13:14
  • okay i lack knowledge knowledge on that; if the app crashes stating cannot load images; u can always use the sampling function of bitmap factory – DJphy Mar 18 '16 at 13:17
  • app is crashing in device Above 22 – tiger Mar 18 '16 at 13:19
  • due to bitmap , so i m switiching to Aquery – tiger Mar 18 '16 at 13:19
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/106723/discussion-between-djphy-and-tiger). – DJphy Mar 18 '16 at 13:22

0 Answers0