私は今、いくつかの質問への回答を使用して、憎悪に満ちたメッセージを含むメールを作成するアプリを作成しています。写真を撮ってその人に電子メールで送信できるようにする機能を追加するにはどうすればよいか疑問に思っています。正しく設定されていると思いますが、電子メールで送信する方法がわかりません。私のコードは次のとおりです。まだ追加していない他の情報も提供できます
package com.example.first_app;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
public class Email extends Activity implements View.OnClickListener{
EditText personsEmail, intro, personsName, stupidThings, hatefulAction,
outro;
String emailAdd, beginning, name, stupidAction, hatefulAct, out;
Button sendEmail;
Button takePicture;
ImageView Picture;
final static int Camera_data = 0;
Bitmap bmp;
Intent i;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.email);
initializeVars();
sendEmail.setOnClickListener(this);
takePicture.setOnClickListener(this);
InputStream is = getResources().openRawResource(R.drawable.ic_launcher);
bmp = BitmapFactory.decodeStream(is);
}
private void initializeVars() {
// TODO Auto-generated method stub
personsEmail = (EditText) findViewById(R.id.etEmails);
intro = (EditText) findViewById(R.id.etIntro);
personsName = (EditText) findViewById(R.id.etName);
stupidThings = (EditText) findViewById(R.id.etThings);
hatefulAction = (EditText) findViewById(R.id.etAction);
outro = (EditText) findViewById(R.id.etOutro);
sendEmail = (Button) findViewById(R.id.bSentEmail);
takePicture = (Button) findViewById(R.id.take_Picture);
Picture = (ImageView) findViewById(R.id.iv_Returned_Picture);
}
public void onClick(View v) {
// TODO Auto-generated method stub
convertEditTextVarsIntoStringsAndYesThisIsAMethodWeCreated();
String emailaddress[] = { emailAdd };
String message = "Well hello "
+ name
+ " I just wanted to say "
+ beginning
+ ". Not only that but I hate when you "
+ stupidAction
+ ", that just really makes me crazy. I just want to make you "
+ hatefulAct
+ ". Welp, thats all I wanted to chit-chatter about, oh and"
+ out
+ '\n' + "PS. I think I love you... ";
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "I hate you");
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
startActivity(emailIntent);
}
private void convertEditTextVarsIntoStringsAndYesThisIsAMethodWeCreated() {
// TODO Auto-generated method stub
emailAdd = personsEmail.getText().toString();
beginning = intro.getText().toString();
name = personsName.getText().toString();
stupidAction = stupidThings.getText().toString();
hatefulAct = hatefulAction.getText().toString();
out = outro.getText().toString();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
@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");
Picture.setImageBitmap(bmp);
}
}
}