Android Settings Wallpaper

Source: Internet
Author: User

1. Call the system Intent.action_attach_data, the intent will arouse all the settings wallpaper program and set the contact picture program, the user can choose through chooseactivity:

The intent is a standard intent, so all settings will support

Intent Intent = new Intent (intent.action_attach_data);                Intent.addflags (intent.flag_grant_read_uri_permission);                Intent.putextra ("MimeType", "image/*");                Uri uri = uri.parse (MediaStore.Images.Media                        . Insertimage (Getactivity (). Getcontentresolver (), (                                ( bitmapdrawable) wallpaper). Getbitmap (), NULL, NULL));                Intent.setdata (URI);                Startactivityforresult (Intent, set_wallpaper);

2. Set by Wallpapermanager

This method can be used to set the image as wallpaper directly for all platforms, but it is not possible to crop/adjust the image.

try {    Wallpapermanager wpm = (Wallpapermanager) getactivity (). Getsystemservice (                context.wallpaper_service);    if (wallpaper! = null) {       wpm.setbitmap (bitmap);       LOG.I ("Xzy", "Wallpaper NOT NULL");}    } catch (IOException e) {    log.e (TAG, "Failed to set Wallpaper:" + e);}

You need to declare permissions in Androidmanifest.xml:

<uses-permission android:name = "Android.permission.SET_WALLPAPER"/>

Android Settings Wallpaper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.