Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set wallpaper in android

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to set wallpaper in android". In daily operation, I believe many people have doubts about how to set up wallpaper in android. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to set wallpaper in android". Next, please follow the editor to study!

1. Call the Intent.ACTION_ATTACH_DATA of the system, and the Intent will evoke all the programs for setting wallpaper and setting contact profile pictures. Users can choose through ChooseActivity:

The Intent is a standard Intent, so all settings 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 via WallpaperManager

This method can directly set the picture as wallpaper, which is used for Android systems on all platforms, but cannot crop / adjust the picture.

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:

At this point, the study on "how to set up wallpaper in android" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report