我已经选择了一个图像并且在图像视图中但现在我想使用发送按钮发送相同的图像。如何获取图像,以便如果单击发送按钮,它会选择图像并给出他在如何发送图像方面有多种选择。 发送按钮代码在
下面Button buttonSendImage = (Button) findViewById(R.id.button2);
buttonSendImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");
startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
}
});Button buttonSendImage = (Button) findViewById(R.id.button2);
buttonSendImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");
startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
}
});
答案 0 :(得分:0)
如果我的理解是正确的,您可以使用以下代码:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
// Add your image URI here and send in a button click.
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));
You can use a MIME type of "*/*"