我在该应用程序中有图像厨房应用程序我将所有图像放入drawable-hdpi文件夹中.我在我的活动中调用了这样的图像:
private Integer[] imageIDs = {
R.drawable.wall1, R.drawable.wall2,
R.drawable.wall3, R.drawable.wall4,
R.drawable.wall5, R.drawable.wall6,
R.drawable.wall7, R.drawable.wall8,
R.drawable.wall9, R.drawable.wall10
};
Run Code Online (Sandbox Code Playgroud)
所以现在我想知道我如何使用共享Intent我分享这些图像我推出的共享代码如下:
Button shareButton = (Button) findViewById(R.id.share_button);
shareButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + imageIDs);
sharingIntent.setType("image/jpeg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
}
});
Run Code Online (Sandbox Code Playgroud)
当我点击分享按钮时我也有共享按钮分享框正在打开但当我克服任何服务时,大多数崩溃或一些服务说:无法打开图像所以我怎么能解决这个问题或者是否有任何其他格式代码来共享图像????
编辑:
我尝试使用下面的代码.但它不起作用.
Button shareButton = (Button) findViewById(R.id.share_button);
shareButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("android.resource://com.android.test/*");
try { …Run Code Online (Sandbox Code Playgroud)