How to send audio file from firebase on whatsapp - android-studio

I have a firebase and few audio files on him, and I have the download url.
I want to send the audio file on whatsapp, how can I do this?
I wrote this:
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("audio/*");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(audioUrl));
try {
context.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
//ToastHelper.MakeShortText("Whatsapp have not been installed.");
}
and when I choose who I want to send him I got this error: Failed to share
How can I fix that?
EDIT:
The error said: "Failed to share" and I see it on the screen like toast message.

Related

Discord bot: How to play an mp3 file in a voice channel

I have made a custom discord bot for a fan server, which is hosted by Heroku so it can stay online when I'm not. What I want to do is to have the bot play an mp3 file from its folder when someone gives a specific command for it, but I want the music to play in a specific voice channel.
First, I tried treating it, the same as an image file. For example:
if (message.content == "Play the Funky Tune.")
{
message.reply("Of course, I hope you enjoy!", { files: ["./Music/FunkyTune.mp3"] });
}
However this causes the bot to put the music file there, and while you can click on it and play it, the moment you click on another channel, the music is paused. I want it to play the song in a specific voice channel so that it continues playing when the user clicks on another channel.
When doing research for this, every topic is always asking for a YouTube video link, which converts it into audio, but this is not what I want, since anything can happen to YouTube videos.
P.S. I am not interested in using already made bots, I want to integrate this music feature into my own bot.
if (message.content == "Play the Funky Tune.") {
// Checking if the message author is in a voice channel.
if (!message.member.voice.channel) return message.reply("You must be in a voice channel.");
// Checking if the bot is in a voice channel.
if (message.guild.me.voice.channel) return message.reply("I'm already playing.");
// Joining the channel and creating a VoiceConnection.
message.member.voice.channel.join().then(VoiceConnection => {
// Playing the music, and, on finish, disconnecting the bot.
VoiceConnection.play("./Music/FunkyTune.mp3").on("finish", () => VoiceConnection.disconnect());
message.reply("Playing...");
}).catch(e => console.log(e))
};
Note that you must run the following commands in order for this to work:
npm install ffmpeg-static
npm install #discordjs/opus

DialogFlow - send custom payload for telegram such as video

Folks.
I need to send video file from dialog flow as URI to telegram user.
Tried:
{
"telegram": {
"video": "https://"
}
}
Tried to guess JSON format for fulfillment message via "payload" but nothing works.
And I could not find documentation about the required format.
How to do it ?
So apparently you cannot send a video in Telegram. According to doc the only supported rich responses are Image, Card, Quick Replay, and Custom Payload (which includes text and hyperlink). If you want to send the link here's the format of custom response:
{
"telegram": {
"text": "You can read about *entities* [here](/docs/concept-entities).",
"parse_mode": "Markdown"
}
}

Is it possible to send the location from Telegram to Bot?

Is it possible to send the location from Telegram to Bot, which made in Bot Framework?
I send my location from my Telegram account to my Bot, but the server does not get them (I don't get the response).
Text messages send normal, and I get response from the server.
Code is very simple:
public async Task<Message> Post([FromBody]Message message)
{
return message.CreateReplyMessage("Tadaa");
}
Dang it, this is a bug. We are filtering out messages without content and we are not treating the location property as "content". To us it looks like no text, no attachments, no channeldata and so no reason to send the message. I will push through a fix.

How to send Image in android from my app to other app?

I wants to send an image stored in the drawable folder to some other app using ACTION_SEND ,my code is given below:
if(view.getId()==R.id.sendimage) {
Uri imageUri=Uri.parse("android.resource://"+getPackageName()+"/drawable"+R.drawable.screen)‌​;
intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM,imageUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
chooser=intent.createChooser(intent,"Send Image Via");
startActivity(chooser);
}
But when i try to send using button in my app to Gmail a toast message "Can't attach empty file " appears and similar message also appear in other apps too while sending and some app even crashes.
So could you please help me in figuring out the mistake??

Unable to load BODYSTRUCTURE exception with an email containing an .eml file sent using Thunderbird

We have an application that accesses an Gmail account (IMAP) using Java Mail API. Works fine for all types of emails except for a message that contains an .eml file as attachment and the message is sent using Thunderbird.
Here is the exception stack trace when trying to retrieve that message . Please advise.
Caused by: com.google.code.javax.mail.MessagingException: Unable to load BODYSTRUCTURE
at com.google.code.com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1377)
at com.google.code.com.sun.mail.imap.IMAPMessage.getContentType(IMAPMessage.java:492)
I had success using this method. In short, if your Message is of type MimeMessage and if you are having this exception, create a new instance of MimeMessage from the original MimeMessage and work on it instead. For example, I was getting this error when I called getContent() method of the Message, so I wrote this method to get content:
private Object getEmailContent(Message email) throws IOException, MessagingException {
try {
return email.getContent();
} catch (MessagingException e) {
// handling the bug
if (email instanceof MimeMessage && "Unable to load BODYSTRUCTURE".equalsIgnoreCase(e.getMessage())) {
return new MimeMessage((MimeMessage) email).getContent();
} else {
throw e;
}
}
}
What version of JavaMail are you using?
You might be running into one of the Gmail bugs described here.
GMail is known to produce malformed BODYSTRUCTURE responses, see e.g. this message from their representative. Last time I checked (mid-2012), it remained unfixed.
Another possibility is that the file representing the emails are deleted from the mail server manually which result in the index(index file) created by the email server being wrong. This can cause the same error.
I was using Mail Enable and the solution is to delete the index file(_index.xml in my case)

Resources