Android 应用程序拍摄/通过电子邮件发送照片
我目前正在编写一个应用程序,在某个活动中,我们希望用户能够拍摄照片并将其通过电子邮件发送到所需的电子邮件地址。我可以分别执行这两项操作(拍照并发送照片),但是当我一起运行它们时,电子邮件客户端列表会出现在相机上......我似乎无法弄清楚为什么它没有运行在相机本身之后..有什么帮助吗?
***这是我现在拥有的:
public class PhotoHandler extends Activity {
private final static int TAKE_PHOTO_CODE = 1;
File downloadedPic = null;
Intent in;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mnwv_main);
downloadedPic = takeandReturn(this);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
try {
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");
picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
picMessageIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{});
picMessageIntent.putExtra(Intent.EXTRA_SUBJECT, "MNWV - Check Out This Photo!");
picMessageIntent.putExtra(Intent.EXTRA_TEXT , "*** Please Describe the Photo Taken Below (Include Your Name, Location, etc.)... ***");
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();
}
}
I am currently writing an app that within a certain activity, we want the user to be able to take and email a photo to a desired email address. I am able to do both of these (take a photo, and send a photo) separately, BUT when I run them together, the email client list comes up over the camera... I cant seem to figure out why it is not running after the camera itself.. Any help?
***Here is what I have now:
public class PhotoHandler extends Activity {
private final static int TAKE_PHOTO_CODE = 1;
File downloadedPic = null;
Intent in;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mnwv_main);
downloadedPic = takeandReturn(this);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
try {
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");
picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
picMessageIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{});
picMessageIntent.putExtra(Intent.EXTRA_SUBJECT, "MNWV - Check Out This Photo!");
picMessageIntent.putExtra(Intent.EXTRA_TEXT , "*** Please Describe the Photo Taken Below (Include Your Name, Location, etc.)... ***");
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 startActivityForResult 来拍照。之后,您必须使用 onActivityResult 发送电子邮件:
希望它会有所帮助。
You must use startActivityForResult for taking the photo. After that you must use onActivityResult to send email:
Hope it will help.