简体   繁体   English

Android:与其他应用上的Intent共享位图

[英]Android: Sharing Bitmap with Intents on other apps

I have a bitmap file that I created using Android Query: 我有一个使用Android查询创建的位图文件:

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. bmp是一个全局初始化的变量,我通过上面的代码和NOT NULL正确地保存了它。

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 我想在Fb,insta等上分享图片

Save bitmap to external storage and get path of the bitmap image 将位图保存到外部存储并获取位图图像的路径

then pass the Uri.parse(path) to the intent. 然后将Uri.parse(path)传递给意图。

for more information refer to this link http://developer.android.com/training/sharing/send.html 有关更多信息,请参考此链接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:"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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