Android Intent Share using external image url -


I can not help seeing that all instances of sharing images with intent whenever locally stored files I try to use external URL, Facebook, Twitter etc. I call a toast, "One or more media items can not be added."

Do I need to store the copy of the image locally? If so, how do I do this?

thanks for the user2245247 correct answer for sharing pictures from remote URLs.
Use external library

  // Get access to image view image view ivImage = (ImageView) findViewById (R.id.ivResult); // Picasso.with (context) to load fire assent request image .load (imageUrl) .into (ivImage);   

After successfully loading the image into an image view, trigger the method for the purpose of sharing.

  // can be triggered by a visual event such as the public zeros press on Share Button (See V) {// View Bitmap Image from View Image Image iv Image = ( ImageView) GetViewById (RIID // Bitmap URI get access to URI for bmpUri = getLocalBitmapUri (ivImage); if (BMPRI! = Null) {// Build a ShareIntent with Link of Immediate ShareIntent = New Intent () ; ShareIntent.setAction (Intent.ACTION_SEND); ShareIntent.putExtra (Intent.EXTRA_STREAM, BMPRI); sh Launch the sharing dialog to start the image ("image / *"); // (Image intent, "Share Image"));} Else {// ... Sharing failed, Handle error}} // Returns the URI path to the bitmap displayed in the specified YouTube public URI getLocalBitmapUri (ImageView imageView) {// Extract ImageView drawable from the bitmap Drawable drawable = imageView.getDrawable (); Bitmap BMP = Faucet; if (to make bitmap driving Eligible Example) {BMP = ((BitmapDableable) imageView.getDrawable ()). GetBitmap (); } And {return tap; } // store image default to external storage directory; URI bmpUri = null; {File file = new file (try the Environment GateInstinstoraz Public Directory (Environmental DIRECTORY_DOWNLOADS), "share_image_" + System.currentTimeMillis () + ".png"); File.getParentFile () mkdirs () .; FileOutputStream Out = New FileOutputStream (File); Bmp.compress (bitmap.compress format.png, 90, out); Out.close (); BmpUri = Uri.framefile (file); } Hold (IOException e) {e.printStackTrace (); } Return BMPURI; }   

Be sure that you have the following permissions.

  Use of Android - Permission: Name = "android.permission.WRITE_EXTERNAL_STORAGE" /> & Lt; Usage-permission Android: name = "android.permission.READ_EXTERNAL_STORAGE" />    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -