bhsu
bhsu

Reputation: 402

setWallpaper(bitmap) doesn't set fullscreen wallpaper?

so I am trying to create an app where the user can press a button to take an image with the phone's camera, and then press another button to set that image as the phone's wallpaper.

I started the camera intent with this: (this is in an onClick method)

Intent i;

i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i, cameraResults);

Then I implemented this method to receive the image from the camera:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == RESULT_OK){
        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        imageView.setImageBitmap(bmp);
    }
}

Then, in the onClick method of the button that sets the wallpaper as the bmp, i used:

getApplicationContext().setWallpaper(bmp);

When I run this app, everything seems to work perfectly! The picture is taken, I set an imageView as the picture, and then when i press the button to set the image as my wallpaper, my wallpaper changes.

HOWEVER, the problem is that the image from the camera doesn't correctly set as the wallpaper. For some reason, the picture decreases in size, so that only the middle of the wallpaper is that image. Most of the screen is black. The image was scaled down for some reason. I want the picture to be full screen, but right now, it is minimized, and the background is black.

Does anyone have any idea why this is? I am following a tutorial video, and the person in the tutorial gets it working perfectly (the image is set as the wallpaper full screen).

I appreciate all help, thank you very much!

Anyone else know how I can scale it so that I set the wallpaper fullscreen?

Upvotes: 1

Views: 1097

Answers (1)

sshturma
sshturma

Reputation: 1151

The bitmap that you are extracting is a thumbnail of your image. Try this Android official tutorial on using native camera app and image scaling.

Upvotes: 1

Related Questions