Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Send a text file through Xamarin Forms to WhatsApp

$
0
0

I would like to send a text file through Xamarin to WhatsApp...

string path2 = Application.Context.FilesDir.Path;
var filePath = Path.Combine(path2, "test.txt");
System.IO.File.WriteAllText(filePath, "Hello World");

Intent sendIntent = new Intent();
sendIntent.SetAction(Intent.ActionSend);
sendIntent.PutExtra(Intent.ExtraText, "Lista de Precos");

Java.IO.File file = new Java.IO.File(filePath);
Android.Net.Uri uta;

uta = Android.Net.Uri.FromFile(file);

or

uta = Android.Net.Uri.Parse("file:///" + filePath);

sendIntent.PutExtra(Intent.ExtraStream, uta);

sendIntent.SetType("text/plain");
sendIntent.SetPackage("com.whatsapp");
StartActivity(sendIntent);

I would like send the text file to WhatsApp....

Thank you,
Rogério
Mail: rogerio.ricardo@uol.com.br


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>