2013-10-28 136 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 "*/*"