Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final String myUrlStr = newString;
- URL url;
- Uri uri=null;
- try {
- url = new URL(myUrlStr);
- uri = Uri.parse( url.toURI().toString() );
- } catch (MalformedURLException e1) {
- e1.printStackTrace();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- try {
- image = MediaStore.Images.Media.getBitmap(this.getContentResolver(),uri);
- } catch (IOException e) {
- e.printStackTrace();
- }
- setButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- WallpaperManager wallpaperManager=WallpaperManager.getInstance(getApplicationContext());
- try {
- // Set the image as wallpaper
- if(image!=null)
- wallpaperManager.setBitmap(image);
- else
- Toast.makeText(getApplicationContext(), "No image was chosen.", Toast.LENGTH_LONG).show();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- });
Add Comment
Please, Sign In to add comment