在Android应用程序中拍摄并发送照片

在Android应用程序中拍摄并发送照片,android,email,camera,message,photo,Android,Email,Camera,Message,Photo,我目前正在尝试从我的应用程序中拍摄并发送照片。我已经用不同的方式处理过了,但我要么在拍照前就可以选择如何发送电子邮件,要么根本就不发送。我需要发送图片,然后选择消息客户端。有什么帮助吗 public class PhotoHandler extends Activity { private final static int TAKE_PHOTO_CODE = 1; File downloadedPic; Intent in; boolean taken = false; @Overrid

我目前正在尝试从我的应用程序中拍摄并发送照片。我已经用不同的方式处理过了,但我要么在拍照前就可以选择如何发送电子邮件,要么根本就不发送。我需要发送图片,然后选择消息客户端。有什么帮助吗

public class PhotoHandler extends Activity {

private final static int TAKE_PHOTO_CODE = 1;
File downloadedPic;
Intent in;
boolean taken = false;

  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  if (!taken) {
  downloadedPic = takeandReturn(this, taken);

  if (taken){
    try {            
        Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);            
        picMessageIntent.setType("image/jpeg");
        picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
        startActivity(Intent.createChooser(picMessageIntent, "Send Picture Using: "));
    } catch (Exception e) {
            Log.e("TAG", "sendPictureMessage() failed to start activity.", e);
            Toast.makeText(this, "No handler", Toast.LENGTH_LONG).show();
    }
  }
  }

}  

private File getTempFile(Context context){
//it will return /sdcard/image.tmp
final File path = new File( Environment.getExternalStorageDirectory(), context.getPackageName() );
if(!path.exists()){
  path.mkdir();
}
return new File(path, "image.jpg");
}

private File takeandReturn(Context context, boolean b) {
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(this)) ); 
startActivityForResult(intent, TAKE_PHOTO_CODE);

final File path = new File( Environment.getExternalStorageDirectory(), context.getPackageName() );
if(!path.exists()){
  path.mkdir();
}

b=true;
return new File(path, "image.jpg");
}       
}
查看此教程

还有这个文档