Load Image With Picasso to a bitmap first


I'm using Picasso. And i want to add the image to bitmap first and then add it to an imageview. I'm using the following line of code that adds an image from gallery with uri and show it on image view. I want to save it on a bitmap first. what should i do:


but i want to save it on a bitmap first.


Picasso holds Target instance with weak reference. <br /> So it is better to hold Target as instance field.<br /> see: <a href="https://stackoverflow.com/a/29274669/5183999" rel="nofollow">https://stackoverflow.com/a/29274669/5183999</a>

private Target mTarget; void loadImage(Context context, String url) { final ImageView imageView = (ImageView) findViewById(R.id.image); mTarget = new Target() { @Override public void onBitmapLoaded (final Bitmap bitmap, Picasso.LoadedFrom from){ //Do something ... imageView.setImageBitmap(bitmap); } @Override public void onBitmapFailed(Drawable errorDrawable) { } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } }; Picasso.with(context) .load(url) .into(mTarget); }


You can do like this

private Target image; image = new Target() { @Override public void onBitmapLoaded (final Bitmap bitmap, Picasso.LoadedFrom from){ new Thread(new Runnable() { @Override public void run() { File file = new File(Environment.getExternalStorageDirectory().getPath() + "/" + FILEPATH); try { file.createNewFile(); FileOutputStream outstream = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 75, outstream); outstream.close(); } catch (Exception e) { e.printStackTrace(); } } }).start(); } } Picasso.with(this) .load(currentUrl) .into(image);


  • IOS: automatic reference counting
  • C++ design pattern: multiple ways to load file
  • Change color of row programmatically in WatchKit
  • Making Cross Site Asynchronous HTTP Post from GWT Client
  • Connect Node.js with Oracle on Windows platform
  • HALF_PTR Windows data type
  • Aligning image on right side of title on UIButton with imageEdgeInsets and titleEdgeInsets
  • Can XOR be expressed using SKI combinators?
  • F#: In which memory area is the continuation stored: stack or heap?
  • Most efficient way to move table rows from one table to another
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • GAE: Way to get reference to an HttpSession from its ID?
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • What is the purpose of TaskExecutor in spring?
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Highlight one bar in a series in highcharts?
  • Seeking advice on Jetty HttpClient Hang
  • Why is an OPTIONS request sent to the server?
  • Retrieving value from sql ExecuteScalar()
  • Spring security and special characters
  • RectangularRangeIndicator format like triangular using dojo
  • Cross-Platform Protobuf Serialization
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Javascript + PHP Encryption with pidCrypt
  • Calling of Constructors in a Java
  • Circular dependency while pushing http interceptor
  • PHP: When would you need the self:: keyword?
  • Revoking OAuth Access Token Results in 404 Not Found
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • Hits per day in Google Big Query
  • Getting Messege Twice Using IMvxMessenger
  • Change div Background jquery
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Checking variable from a different class in C#
  • reshape alternating columns in less time and using less memory
  • How can i traverse a binary tree from right to left in java?
  • How can I use threading to 'tick' a timer to be accessed by other threads?