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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:11:18+00:00 2026-06-06T22:11:18+00:00

i am new to android development. I am use the following code to set

  • 0

i am new to android development. I am use the following code to set the wallpaper to every home screen. In this code first it ll ask the user to enter the home screen availability numbers.

The user giving the input that they are having 3 home screen means it will ask them to select three wallpapers from sdcard and i am get that three images and change it to device default screen size and combine that bitmap images and set it as a home screen wall paper.

  public void onCreate(Bundle savedInstanceState) {
         Display display = getWindowManager().getDefaultDisplay();
    dwidth = display.getWidth();
    dheight = display.getHeight();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);          
    Log.i("WALLPAPER", "" + dwidth);
    Log.i("WALLPAPER", "" + dheight);
    width1 = dwidth;
    height1 = dheight;
    scno = (EditText) findViewById(R.id.screenno);
    image = (ImageView) findViewById(R.id.imageview1);
    wallpaper=(Button) findViewById(R.id.setwallpaper);
    selectimage = (Button) findViewById(R.id.selectimg);
    selectimage.setVisibility(View.VISIBLE);
    selectimage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if(scno.getText().toString().length()<=0){
        Toast.makeText(getApplicationContext(),"Enter The number Of Screen",Toast.LENGTH_LONG).show();
            }
            else{
            nmscreen = scno.getText().toString();               
            noofscreen = Integer.parseInt(nmscreen);            
            Log.i("WALLPAPERDEMO", "" + noofscreen);                
            Intent intent1=new Intent();
            intent1.setType("image/*");
            intent1.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent1, "Complete action using"), PICK_FROM_FILE);             
            }
        }
    });

    wallpaper.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if(scno.getText().toString().length()<=0){
                Toast.makeText(getApplicationContext(),"Enter The Number Of Screen",Toast.LENGTH_LONG).show();
            }
            else{
            WallpaperManager mywallpapermanager=WallpaperManager.getInstance(getApplicationContext());

            try{
                mywallpapermanager.setBitmap(change);
                selectimage.setEnabled(true);

            }catch (IOException e) {
                // TODO: handle exception
                e.printStackTrace();
            }
            image.setImageBitmap(null);
            scno.setText("");
        }
        }

    });
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK)return;
    Log.d("WALLPAPERDEMO", "Count: " + count);
    switch (requestCode) {
        case PICK_FROM_FILE:
            mImageCaptureUri = data.getData();
            Log.i("WALLPAPERDEMO","Calling doCrop() "+mImageCaptureUri.toString());
            doCrop();
            break;
        case CROP_FROM_CAMERA:          
            Bundle extras = data.getExtras();
            if (extras != null) {               
                photo = extras.getParcelable("data");               
                Log.d("WALLPAPERDEMO",""+photo.getWidth());                 
                Log.d("WALLPAPERDEMO",""+photo.getWidth());
                bitmapArray.add(photo);
                 count++;
                 Log.d("WALLPAPERDEMO","Count"+count);
                 if(count<noofscreen){
                        Log.d("WALLPAPERDEMO","Outside Switch"+count);
                        Intent intent1=new Intent();
                        intent1.setType("image/*");
                    intent1.setAction(Intent.ACTION_GET_CONTENT);
                        startActivityForResult(Intent.createChooser(intent1, "Complete action using"), PICK_FROM_FILE);
                 }else{
                     firstimage = new Bitmap[count];
                        for (i = 0; i <count; i++) {
                            firstimage[i] = bitmapArray.get(i);
                        }
                        setImage(firstimage);
                        selectimage.setEnabled(false);
                 }
                File f = new File(mImageCaptureUri.getPath());            
                if (f.exists()) f.delete();
                break;
        }           
    }               
}       

private void setImage(Bitmap[] firstimage) {

    change = Bitmap.createScaledBitmap(firstimage[0], width1, height1, true);
    for(int i=1;i<firstimage.length;i++){
            Log.d("WALLPAPERDEMO", "" + firstimage[i].getWidth());
            Log.d("WALLPAPERDEMO", "change " + change.getWidth());
            change1 = Bitmap.createScaledBitmap(firstimage[i], width1, height1, true);
            Log.d("WALLPAPERDEMO", "change1 " + change1.getWidth());
            change = combineImages(change, change1);
            Log.d("WALLPAPERDEMO", ""+change.getWidth());
    }

    image.setImageBitmap(change);

}

public Bitmap combineImages(Bitmap change1, Bitmap change) {
    Bitmap cs = null;
    int width, height = 0;

    if (change1.getWidth() > change.getWidth()) {
        width = change1.getWidth() + change.getWidth();
        height = change1.getHeight();
    } else {
        width = change.getWidth() + change1.getWidth();
        height = change.getHeight();
    }
    cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas comboImage = new Canvas(cs);

    comboImage.drawBitmap(change, 0f, 0f, null);
    comboImage.drawBitmap(change1, change.getWidth(), 0f, null);
    return cs;

}

I am run this application and check it with the real device for some of the devices its working perfectly. But in some devices the screen size is not fitted. what is the problem in my code. I am getting the default screen size of the device and for combining images i am change the selected bitmap images into default screen size then only combine the image and set it as a wallpaper.

Please help me to set a wallpaper to every home screen. Thanks in advance.

  • 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-06T22:11:21+00:00Added an answer on June 6, 2026 at 10:11 pm

    xlarge screens are at least 960dp x 720dp
    large screens are at least 640dp x 480dp
    normal screens are at least 470dp x 320dp
    small screens are at least 426dp x 320dp

    Save your resource in this folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Android development. I am trying to use the following code
I'm new to Android application development. I would like to ask the use of
I'm pretty new to Android Development, i'm following some Youtube tutorials currently. I'd like
hey, im new to android development and trying to make my first application. What
I'm new to Android development and I wonder if I can use some Java
I am new to Android Development. For my project, I need to use REST
Im new to android development. Now im trying to use sqlite db. I created
I'm new in android development and I'll appreciate any help for implementing the following
Im new to android development. Now im trying to use sqlite db. I created
I am totally new to android development....what piece of code shall I write to

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.