简体   繁体   中英

Android: Sharing Bitmap with Intents on other apps

I have a bitmap file that I created using Android Query:

aq = new AQuery(HomeCategoryActivity.this);
aq.ajax(currentUrl,Bitmap.class,0,new AjaxCallback<Bitmap>(){
        @Override
        public void callback(String url, Bitmap object, AjaxStatus status) {
            if(object != null)
            {
                bmp = object;
            }
        }
    });

bmp is a globally initialized variable and it gets properly saved by the above code and NOT NULL, I checked.

Now I want to share this bitmap on other apps using this:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(bmp));
startActivity(Intent.createChooser(intent, "Share Product via:"));

This won't work since the code is probably wrong. What changes should I make?

I want to share the image on Fb, insta, etc

Save bitmap to external storage and get path of the bitmap image

then pass the Uri.parse(path) to the intent.

for more information refer to this link http://developer.android.com/training/sharing/send.html

Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/jpeg");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.parseUri(path));
    startActivity(Intent.createChooser(intent, "Share Product via:"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM