Delphi as we always have
In Delphi XE7 start a new project Multi-Device Project. We will select the Target Platform Android through Project Manager, enjoy and also select the target device (Target option) where the deploy after the build is done. See the image below:
Building the application screen
Let's build a simple interface, it will have only the components and properties as listed below:
Edit1
Align -> Top
Text -> "
ReturnKeyType -> Done
Image1
MultiResBitmap -> [An image of your choice]
WrapMode -> Stretch
Button1
Text -> 'Send Whatsapp'
As I mentioned something very simple, only for teaching purposes.
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 www.vivaitaocara.com.br/landersongomes/ blog' 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;
Check the result
Well just compile and test, check the images below that worked perfectly. Party did not get success was still select the contact previously, but will continue trying to go up and getting an update.
this project need FMX.Helpers.Android.dcu
source:http://vivaitaocara.com.br/landersongomes/delphi/integrando-aplicativo-delphi-xe7-android-com-whatsapp
No comments:
Post a Comment