I am trying to share a file with message via email or other tools like whatsapp using intent chooser. I want the message to have a link to a website, such as:
Click it to search: Google
Where Google is a hyperlink to https://www.google.com
To send a message with hyperlink, I guess I need the message to be in html like:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/html");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<p>This is the text shared.</p>"));
startActivity(Intent.createChooser(sharingIntent, "Share using"));
The file is a gpx (e.g. “filea.gpx) with mine type “application/gpx+xml". For file, I would need something like:
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
final File photoFile = new File(getFilesDir(), "foo.jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile));
startActivity(Intent.createChooser(shareIntent, "Share image using"));
I am able to send a message using type "application/gpx+xml
" for an attached file, together with a plain text message but not hyperlink.
How can I put 2 together in one intent? i.e. to have html message text with type “text/html”, and attached gpx file with type “application/gpx+xml
” at the same time.
Any example on how to specify the hyperlink in the text message will be helpful too.
Thanks,
Nick