在Android的WhatsApp的分享图像 [英] Share image on whatsapp in android

查看:255
本文介绍了在Android的WhatsApp的分享图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要上什么应用共享图像和我们聊....等等.........
我有图像对GridView控件....每个图像点击必须将开放共享型的选择..
但是累了本作code ..... plz帮助我.....任何想法.....
我下面code。

  grid_view.setOnItemClickListener(新OnItemClickListener(){
    @覆盖
    公共无效onItemClick(适配器视图<>母公司,查看paramView,INT位置,长的id){
        字符串路径=将String.valueOf(位置);
        意图sharingIntent =新意图(Intent.ACTION_SEND);        乌里screenshotUri = Uri.parse(路径);
        sharingIntent.setType(图像/ *);
        如果(sharingIntent!= NULL){
            sharingIntent.putExtra(Intent.EXTRA_STREAM,screenshotUri);
            sharingIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse(android.resource:///绘制/+路径+.JPG));
            sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(Intent.createChooser(sharingIntent,分享图像使用));
        }
        其他{
            Toast.makeText(getApplication(),Plase尝试agian,2000年).show();
        }    }
});


解决方案

下面是code共享意图。

  sendBroadcast(新意图(Intent.ACTION_MEDIA_MOUNTED,Uri.parse(文件://+ Environment.getExternalStorageDirectory())));意图sendIntent =新意图(Intent.ACTION_SEND);sendIntent.setType(图像/ PNG);
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(新文件(mScreenshotPath +/+ curentDateandTime +PNG)));
startActivityForResult(sendIntent,0);

i want to share image on whats-app and we-chat....and so on......... i have image's on gridview....to each image click must will be open shareing option.. but m tired this make code.....plz help me.....and any idea..... and my code below.

grid_view.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View paramView, int position, long id) {
        String path=String.valueOf(position);
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);

        Uri screenshotUri = Uri.parse(path);
        sharingIntent.setType("image/*");
        if (sharingIntent !=null) {
            sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
            sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource:///drawable/" +path + ".jpg"));
            sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(Intent.createChooser(sharingIntent, "Share image using"));    
        }
        else {
            Toast.makeText(getApplication(), "Plase try agian", 2000).show();
        }

    }
});    

解决方案

Here is the code for sharing intent.

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));    

Intent sendIntent = new Intent(Intent.ACTION_SEND);     

sendIntent.setType("image/png");
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(mScreenshotPath+"/"+curentDateandTime+".png")));
startActivityForResult(sendIntent, 0);

这篇关于在Android的WhatsApp的分享图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆