在这里,我将我的应用程序中的图像分享到 whatsapp。但此代码仅适用于 mylist1[i],不适用于 mylist2[i] 和 mylist3[i]。在我的 Activity 文件中,每个列表中有 15 张图像。怎么办?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
Uri uri = Uri.parse("android.resource://com.example.drawcelebrities/"+mylist1[i]+mylist2[i]+mylist3[i]);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share via"));
最佳答案
在 mylist[] 中获取图像数组并使用下面的代码,然后通过 whatsapp 分享图像。
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+mylist[i]);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "Share via"));
关于android - 如何将我的应用程序中的图像分享到 whatsapp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22602963/