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 8461863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:59:51+00:00 2026-06-10T13:59:51+00:00

I’ve been trying to solve this issue for 2 hours and i haven’t found

  • 0

I’ve been trying to solve this issue for 2 hours and i haven’t found the solution yet.

My activity has the option of taking a photo with the camera API or to browse an image from gallery. I can get the image and display it in the SAME ACTIVITY but the problem is that i need it in other activity too.

As far as i know,the best way to do this is by storing the image in the SD card but i’ve tried to do it and i only get errors and errors.

Could you please give me a hand?

Thanks!

    public void onClick(View arg0) {

    // TODO Auto-generated method stub
    switch(arg0.getId()){

        case R.id.save:

            if (et.getText() !=null && thumbnail != null){

                 TableRow tr = new TableRow(this);
                 ImageView view = new ImageView(this);
                 TextView view2 = new TextView(this);
                 Button view3 = new Button(this);
                 view3.setOnClickListener(this);



                 view3.setId(i);


                 view.setImageBitmap(thumbnail);
                 view.setPadding(1, 5, 0, 0);
                 view.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

                 Calendar c = Calendar.getInstance();
                 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");

                 titulo[i]=""+et.getText();
                 mensaje[i]=""+et1.getText();
                 fotos[i]=thumbnail;


                 view2.setText(titulo[i] +"                 "+ dateFormat.format(c.getTime()) );

                 view2.setGravity(Gravity.CENTER_VERTICAL);
                 view2.setPadding(5, 0, 0, 0);
                 i++;

                 view3.setGravity(Gravity.RIGHT);
                 view3.setGravity(Gravity.CENTER_VERTICAL);

                 DisplayMetrics metrics = new DisplayMetrics();
                 getWindowManager().getDefaultDisplay().getMetrics(metrics);

                 tr.addView(view, metrics.widthPixels/3, 150);
                 tr.addView(view2, metrics.widthPixels/2, 150);
                 tr.addView(view3, metrics.widthPixels/6, 20);
                 tl.addView (tr, 0);


                 final Toast toastMensaje = Toast.makeText(getApplicationContext(),
                            "Tu entrada se cargó correctamente", Toast.LENGTH_SHORT);
                    toastMensaje.setGravity(Gravity.CENTER, 0, 0);
                    toastMensaje.show();

                    et.setText("");
                    et1.setText("");
                    i1.setVisibility(View.GONE);


            }

            else{

                final Toast toastMensaje = Toast.makeText(getApplicationContext(),
                        "Tienes que añadir un título y una foto", Toast.LENGTH_LONG);
                toastMensaje.setGravity(Gravity.CENTER, 0, 0);
                toastMensaje.show();

            }


        break;

        case R.id.photo:

            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);  
            startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);


        break;

        case R.id.gallery:

            Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
             startActivityForResult(intent, TFRequestCodes);

        break;

        default:



            Intent openActivity = new Intent(Second.this, Recuerdos.class);
            openActivity.putExtra("titulo", titulo[arg0.getId()]);
            openActivity.putExtra("mensaje", mensaje[arg0.getId()]);
            openActivity.putExtra("URI", selectedImage);


            startActivity(openActivity);

        break;

    }

}



protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {  
        // do something  

        thumbnail = (Bitmap) data.getExtras().get("data");
        i1.setImageBitmap(thumbnail);



    }  

    else if (requestCode == TFRequestCodes && resultCode == RESULT_OK) {  
        // do something



        selectedImage = data.getData();
        String[] filePathColumn = {MediaStore.Images.Media.DATA};

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

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String filePath = cursor.getString(columnIndex);
        cursor.close();


        thumbnail = BitmapFactory.decodeFile(filePath);
        i1.setImageBitmap(thumbnail);


    }  


}  

}
  • 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-10T13:59:53+00:00Added an answer on June 10, 2026 at 1:59 pm

    You’d rather pass image URI instead of image data.

    In the onActivityResult() method you can get the image URI:

    Uri imageUri = data.getData();
    

    Then you can pass this uri to the other activity when starting it:

        Intent intent = new Intent(context, MyNextActivity.class);
        intent.setData(imageUri);
        startActivity(intent);
    

    And in the next activity you can retrieve this URI:

    Uri imageUri = getIntent().getData();
    

    And then to display the image in an ImageView:

    imageView.setImageURI(imageUri);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.