0
현재 내 앱에서 사진을 찍고 보내려고합니다. 나는 여러 가지 방법으로 주위를 어지럽 혔지 만 사진을 찍기 전에 이메일을 보내는 방법에 대한 옵션을 얻거나 전혀하지 않습니다. 그 다음에 메시징 클라이언트를 선택하는 그림을 보내야합니다. 어떤 도움이 필요합니까?안드로이드 앱 내에서 사진 찍기 및 보내기
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");
}
}