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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:04:37+00:00 2026-06-05T21:04:37+00:00

im new to android and I’ve been trying to figure out how to display

  • 0

im new to android and I’ve been trying to figure out how to display a photo on Android. I’ve been searching all week with no luck and want to know if there are any android sample code or examples on how to set a wallpaper for the app from the image gallery

thank you all

  • 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-05T21:04:40+00:00Added an answer on June 5, 2026 at 9:04 pm

    Use following Method for selecting image from Image Gallary

       //Declare private static final int PICK_IMAGE = 1;
    
      try {
                    Intent intent = new Intent();
                    intent.setType("image/*");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    startActivityForResult(Intent.createChooser(intent, "Select Picture"),  PICK_IMAGE);
                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_LONG).show();
                    Log.e(e.getClass().getName(), e.getMessage(), e);
                }
    

    And On Activity Result Write :

        @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    
        switch (requestCode) {
        case PICK_IMAGE:
    
            if (resultCode == Activity.RESULT_OK) {
                Uri selectedImageUri = data.getData();
                try {
                    // OI FILE Manager
                    String filemanagerstring = selectedImageUri.getPath();
    
                    // MEDIA GALLERY
                    String selectedImagePath = getPath(selectedImageUri);
    
                    if (selectedImagePath != null) {
                        filePath = selectedImagePath;
                    } else if (filemanagerstring != null) {
                        filePath = filemanagerstring;
                    } else {
                        Toast.makeText(getApplicationContext(), "Unknown path",
                                Toast.LENGTH_LONG).show();
    
                    }
    
                    if (filePath != null) {         
    
                        decodeFile(filePath);
                    } else {
                        bitmap = null;
                    }
                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), "Internal  
                         error",Toast.LENGTH_LONG).show();
    
                }
            }
            break;
        default:
        }
    
    
    
    }
    
    
         //Decode file() where you will get decoded file and then you can use that image
          //file according to your requirement
    
       public void decodeFile(String filePath) {
    
        // Decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, o);
    
        // The new size we want to scale to
        final int REQUIRED_SIZE = 1024;
    
        // Find the correct scale value. It should be the power of 2.
        int width_tmp = o.outWidth, height_tmp = o.outHeight;
        int scale = 1;
        while (true) {
            if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE)
                break;
            width_tmp /= 2;
            height_tmp /= 2;
            scale *= 2;  
        }
    
        // Decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        bitmap = BitmapFactory.decodeFile(filePath, o2);
    
        image.setImageBitmap(bitmap);// set ImageView in your case set Layout  
                  //background
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a new android developer. I've been searching for this answer all over SO
I am a new android app developer and i want to use google map
I am new android app developer i want make app for tablets and phone
I'm trying to record audio this.recorder = new android.media.MediaRecorder(); this.recorder.setAudioSource(android.media.MediaRecorder.AudioSource.MIC); this.recorder.setOutputFormat(android.media.MediaRecorder.OutputFormat.DEFAULT); this.recorder.setAudioEncoder(android.media.MediaRecorder.AudioEncoder.DEFAULT); this.recorder.setOutputFile(pruebaAudioRecorder.mp4); **this.recorder.prepare();**
I trying to use the new android compatibility package to include fragments into my
New Android developer here - I'm hoping this is simple. I want to create
Just my a new Android phone and I've been tinkering with some basic apps.
Im a new Android programmer, and my question is this: I want to fetch
I am new to android development and I have been having issues with Force
I am a new android developer trying to write a simple contact book. When

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.