Understanding and encoding
Basically we EDIT1 in a text that will be delivered to Whatsapp for when selecting contact him the message is sent. Now that we have the concept we code.
Remember that we must once again make use of namespaces orUnits for use of Android features in Delphi, for such in theimplementation section enter the:
Implementation
{$ R * .fmx}
uses
FMX.Helpers.Android, Androidapi.Jni.GraphicsContentViewText,
Androidapi.Jni.Net, Androidapi.Jni.JavaTypes, idUri, Androidapi.Jni,
Androidapi.JNIBridge, Androidapi.Helpers;
After that, in the OnClick Button1 we enter the code below:
procedure TForm1.Button1Click (Sender: TObject);
var
IntentWhats: JIntent;
message: string;
begin
Then if Edit1.Text.IsEmpty
message: = 'Whatsapp sending test with Delphi XE7. '+ # 13 +
'Read more in You can't view the links! Click here to register'
else
Message: = Edit1.Text;
IntentWhats: = TJIntent.JavaClass.init (TJIntent.JavaClass.ACTION_SEND);
IntentWhats.setType (StringToJString ('text / plain'));
IntentWhats.putExtra (TJIntent.JavaClass.EXTRA_TEXT,
StringToJString (message));
IntentWhats.setPackage (StringToJString ('com.whatsapp'));
SharedActivity.startActivity (IntentWhats);
end;
Basically we EDIT1 in a text that will be delivered to Whatsapp for when selecting contact him the message is sent. Now that we have the concept we code.
Remember that we must once again make use of namespaces orUnits for use of Android features in Delphi, for such in theimplementation section enter the:
Implementation
{$ R * .fmx}
uses
FMX.Helpers.Android, Androidapi.Jni.GraphicsContentViewText,
Androidapi.Jni.Net, Androidapi.Jni.JavaTypes, idUri, Androidapi.Jni,
Androidapi.JNIBridge, Androidapi.Helpers;
After that, in the OnClick Button1 we enter the code below:
procedure TForm1.Button1Click (Sender: TObject);
var
IntentWhats: JIntent;
message: string;
begin
Then if Edit1.Text.IsEmpty
message: = 'Whatsapp sending test with Delphi XE7. '+ # 13 +
'Read more in You can't view the links! Click here to register'
else
Message: = Edit1.Text;
IntentWhats: = TJIntent.JavaClass.init (TJIntent.JavaClass.ACTION_SEND);
IntentWhats.setType (StringToJString ('text / plain'));
IntentWhats.putExtra (TJIntent.JavaClass.EXTRA_TEXT,
StringToJString (message));
IntentWhats.setPackage (StringToJString ('com.whatsapp'));
SharedActivity.startActivity (IntentWhats);
end;