我正在尝试创建一个应用程序来拍照,然后通过电子邮件发送。最近几天我一直在搞乱我的代码,我尝试了很多不同的东西,但我仍然无法让它工作。我可以拍照没问题,只是当我发送它时我的应用程序崩溃了。请参阅下面的代码:
public class Camera extends Activity implements View.OnClickListener {
ImageButton ib;
Button b;
ImageView iv;
Intent i;
final static int cameraData = 0;
Bitmap bmp;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.photo);
initialize();
InputStream is = getResources().openRawResource(R.drawable.ic_launcher);
bmp = BitmapFactory.decodeStream(is);
}
private void initialize() {
ib = (ImageButton) findViewById(R.id.ibTakePic);
b = (Button) findViewById(R.id.bSendPic);
iv = (ImageView) findViewById(R.id.ivReturnedPic);
b.setOnClickListener(this);
ib.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.bSendPic:
String emailaddress[] = { "info@sklep.com", "", };
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, emailaddress);
// getPackageName() is your app package
Uri path = Uri.parse("android.resource://" + getPackageName()
+ "/ + R.drawable.ic_launcher");
emailIntent.putExtra(Intent.EXTRA_STREAM, path); // Replace your
// line
emailIntent.setType("image/png");
startActivity(Intent.createChooser(emailIntent, "Send Mail"));
/*
* emailIntent.setType("image/jpeg");
*
* emailIntent.putExtra(Intent.EXTRA_STREAM, bmp);
*
* emailIntent.setType("message/rfc822");
* startActivity(Intent.createChooser(emailIntent, "Send Mail"));
*/
break;
case R.id.ibTakePic:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
}
}
}
当我去发送它时,我收到以下错误:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND (has extras)
有人可以帮我吗?谢谢