0

我已经选择了一个图像并在图像视图中,但现在我想使用发送按钮发送相同的图像。我如何获取图像,以便如果单击发送按钮,它会选择图像并为他提供多种选择他如何发送图像的选项。发送按钮代码如下

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:"));  
    }
});
4

1 回答 1

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 "*/*"
于 2013-10-28T08:28:20.733 回答