0

Delphi XE5 (Android App).

Doing a small app and just want to get some feedback .

How can I send an intent to use a simple TEdit for Subject, and Tmemo for Message and send it to the default mail client on the end users phone. Thanks.

joao2fast4u
  • 6,868
  • 5
  • 28
  • 42
grant1842
  • 357
  • 1
  • 7
  • 23
  • 1
    I think the Share Sheet may can do this. – grant1842 Oct 13 '13 at 00:45
  • 4
    Which part are you having trouble with? Invoking an intent? Identifying which intent to use? Some Delphi-specific aspect of one of those things? [Edit] to make your question more specific, please. – Rob Kennedy Oct 13 '13 at 00:46
  • Thanks for your comment. I am looking at the share sheet to attach the text to . I thought we may have to wrap an intent to do it but the share sheet looks promising . – grant1842 Oct 13 '13 at 04:43
  • So, do you still need an answer to the question you asked here? – Rob Kennedy Oct 13 '13 at 05:27

1 Answers1

2

Something like this ought to help the process. Pass in the values from the UI controls.

uses
  FMX.Helpers.Android,
  Androidapi.JNIBridge,
  Androidapi.JNI.JavaTypes,
  Androidapi.JNI.GraphicsContentViewText;
...
procedure CreateEmail(const Recipient, Subject, Content: string);
var
  Intent: JIntent;
  Recipients: TJavaObjectArray<JString>;
begin
  Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_SEND);
  Recipients := TJavaObjectArray<JString>.Create(1);
  Recipients.Items[0] := StringToJString(Recipient);
  Intent.putExtra(TJIntent.JavaClass.EXTRA_EMAIL, Recipients);
  Intent.putExtra(TJIntent.JavaClass.EXTRA_SUBJECT, StringToJString(Subject));
  Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString(Content));
  //Intent.setType(StringToJString('plain/text'));
  Intent.setType(StringToJString('message/rfc822'));
  //SharedActivity.startActivity(Intent);
  SharedActivity.startActivity(TJIntent.JavaClass.createChooser(Intent,
    StrToJCharSequence('Which email app?')));
end;
blong
  • 2,145
  • 13
  • 23