1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| public class MaCLasse extends Activity implements OnClickListener {
static private final String[] email = {"adresse@mail"};
private TextView sendmail;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main_activity);
setupUIEle();
}
private void setupUIEle()
{
sendmail = (TextView) findViewById(R.id.sendmail);
sendmail.setOnClickListener(this);
}
public void onClick(View v)
{
if (v.equals(sendmail))
{
captureImage();
}
}
private void captureImage()
{
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, 1);
}
@override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.v("","test travDetails onAct");
super.onActivityResult(requestCode, resultCode, data);
Uri picUrl = null;
if (data != null) {
picUrl = data.getData();
}
Intent intent= new Intent(android.content.Intent.ACTION_SEND);
intent.setType("jpeg/image");
String head = "Entete\n";
String text = "Envoyé depuis mon smartphone Android\n";
intent.putExtra(android.content.Intent.EXTRA_EMAIL, email);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sujet");
if (picUrl != null) {
intent.putExtra(android.content.Intent.EXTRA_STREAM, picUrl);
}
intent.putExtra(android.content.Intent.EXTRA_TEXT, head + text);
startActivity(Intent.createChooser(intent,"Par mail..."));
}
} |
Partager