Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将多个图像共享到whatsapp应用程序?_Android_Image_Whatsapp_Android Sharing - Fatal编程技术网

Android 如何将多个图像共享到whatsapp应用程序?

Android 如何将多个图像共享到whatsapp应用程序?,android,image,whatsapp,android-sharing,Android,Image,Whatsapp,Android Sharing,如何将多个图像共享到所有共享应用,如(WhatsApp、电子邮件),但当我尝试将多个图像共享到WhatsApp时,收到的消息为:共享失败,请重试。我更改设置类型,但不工作 请检查此链接 请检查以下代码: imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //imageUriArray = new

如何将多个图像共享到所有共享应用,如(WhatsApp、电子邮件),但当我尝试将多个图像共享到WhatsApp时,收到的消息为:
共享失败,请重试。我更改设置类型,但不工作
请检查此链接

请检查以下代码:

imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //imageUriArray = new ArrayList<Uri>();
            toolbar.setVisibility(View.GONE);

            for (int i = 0; i < arrayList.size(); i++) {
                Date now = new Date();
                android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
                aa = screenWidth * i;
                horizontal.scrollTo(aa, 0);


                try {
                    // image naming and path  to include sd card  appending name you choose for file
                    String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + i + ".jpg";

                    // create bitmap screen capture
                    View v1 = myView.getRootView();
                    v1.setDrawingCacheEnabled(true);
                    Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
                    v1.setDrawingCacheEnabled(false);

                    File imageFile = new File(mPath);

                    FileOutputStream outputStream = new FileOutputStream(imageFile);
                    int quality = 100;
                    bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
                    outputStream.flush();
                    outputStream.close();
                    imageUriArray.add(Uri.fromFile(new File(String.valueOf(imageFile))));
                    //openScreenshot(imageFile);
                } catch (Throwable e) {
                    // Several error may come out with file handling or OOM
                    e.printStackTrace();
                }
            }
            toolbar.setVisibility(View.VISIBLE);
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUriArray);
            intent.setType("image/jpeg");
            startActivity(intent);
        }
    });

    arrayList = new ArrayList<>();
    arrayList.add("https://trinitytuts.com/wp-content/uploads/2015/02/trinitylogo.png");
    arrayList.add("http://lh4.googleusercontent.com/-1hHevfC4VTQ/AAAAAAAAAAI/AAAAAAAAAGs/Bi_dipj31f4/photo.jpg?sz=104");

    for (int ii = 0; ii < arrayList.size(); ii++) {
        LayoutInflater inflaters = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        myView = inflaters.inflate(R.layout.pager_item_multi, null);
        layMain = (LinearLayout) myView.findViewById(R.id.layMain);
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        //int screenHeight = metrics.heightPixels;
        screenWidth = metrics.widthPixels;
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(screenWidth, LinearLayout.LayoutParams.MATCH_PARENT);
        ImageView imageViews = (ImageView) myView.findViewById(R.id.img_pager_item);
        Picasso.with(this).load(arrayList.get(ii)).placeholder(R.mipmap.ic_launcher).into(imageViews);
        layMain.setLayoutParams(layoutParams);
        layMain.setTag("" + ii);
        layout.addView(myView);
    }
}
imageView.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
//ImageUrArray=新的ArrayList();
工具栏.setVisibility(View.GONE);
对于(int i=0;i
我在url中传递图像,当点击按钮时,所有图像在WhatsApp上共享


请提供帮助。

与安卓系统上的大多数社交应用程序一样,WhatsApp倾听分享媒体和文本的意图。例如,只需创建共享文本的意图,系统选择器就会显示WhatsApp:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Your image url here.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
但是,如果您希望直接与WhatsApp共享并绕过系统选择器,则可以在您的意图中使用setPackage:

sendIntent.setPackage("com.whatsapp");

这只需在调用startActivity(sendIntent)之前设置即可

我从服务器获取图像url。转换并显示为水平行中的图像视图。并使用whatsapp将所有图像共享给其他人。不共享url链接…这是不可能的,因为whatsapp不支持包含两张图片的消息。