2013-10-28 102 views
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:")); 
    } 
}); 

回答

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 "*/*"