android / input-samples

Multiple samples showing the best practices in input on Android.
Apache License 2.0
288 stars 265 forks source link

Whatsapp is not supported #11

Open regiszanandrea opened 7 years ago

regiszanandrea commented 7 years ago

Hi,

I'm developing a custom keyboard that have to send images to Messenger and Whatsapp conversasions. So, I called the function isCommitContentSupported(...,MIME_TYPE_PNG) on Whatsapp and returned false, and a called the same function on Messenger app and returned true. The Commit Content is not supported on Whatsapp.

Anybody can help? There is an alternative?

LeonardooBorges commented 6 years ago

Hello! I was trying to do the same thing, my solution was to convert the image file to gif and then send it. Whatsapp does support sending gif. Hope this help.

regiszanandrea commented 6 years ago

Hi Leonardo,

Can you paste your code here? Or email me ? regiszanandrea@gmail.com

Thanks.

LeonardooBorges commented 6 years ago
private File convertToGif(File imageFile) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    AnimatedGifEncoder encoder = new AnimatedGifEncoder();
    encoder.start(bos);
    encoder.addFrame(BitmapFactory.decodeFile(imageFile.getAbsolutePath()));
    encoder.finish();
    byte[] array = bos.toByteArray();

    // Save to file
    File output = new File(Environment.getExternalStorageDirectory(), "output.gif");
    FileOutputStream fos = new FileOutputStream(output.getPath());
    fos.write(array);
    fos.close();
    return output;
  }

And I use this code https://gist.github.com/wasabeef/8785346

Any questions you have I can try to help :)

regiszanandrea commented 6 years ago

Sorry, I didn't see your answer. Thanks a lot, I will test this code.

regiszanandrea commented 6 years ago

Hi @LeonardooBorges, how do you pass to the doCommitContent the file? I'm getting a error, but I can't tracking the erro by the logcat :(

regiszanandrea commented 6 years ago

Another thing, I converted the images to gif, and the whatsapp return the message "The format its not supported". Jesus Christ.....

prashantvr commented 6 years ago

Yes, I am facing the same issue. "The file format is not supported". Have followed the sample, have 3 buttons for gif, png and webp. While nothing happens on clicking png and webp, gif throws "the file format not supported" error.

Any help??

diskrim commented 6 years ago

I am having the same issue here. The pngs/gifs are working fine in fb messenger & google hangouts, but not whats app or even the native message app. GIF or not does not allow it. The sample app is flawed as a demo. I am thinking to make a copy paste functionality here, and make use of the clipboard as I have on the ios version.

ok3141 commented 6 years ago

Guys, you must override and correctly implement method ContentProvider.getType()