how to send image or video to whatsapp status in android programmatically?
Asked Answered
D

1

7

How to send image or video to the WhatsApp Status (or story) in android.

we can send an image to contact by using:

Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.putExtra(Intent.EXTRA_STREAM, imageURI);
sendIntent.putExtra("jid", "91"+mobile + "@s.whatsapp.net");
sendIntent.putExtra(Intent.EXTRA_TEXT, "whatsapp image caption");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setPackage("com.whatsapp");
sendIntent.setType("image/*");

But how to send it to my whatsapp status?

Dunson answered 25/8, 2018 at 18:55 Comment(1)
did you get an answer to do it?, the app of TikTok is able to show an option to share it bt WhatsApp status, IDK how they did thatHulbard
S
-2
private void shareToWhatsApp() {
    String type = "video/*";

    // Create the new Intent using the 'Send' action.
    Intent share = new Intent(Intent.ACTION_SEND);

    // Set the MIME type
    share.setType(type);

    // Create the URI from the media
    Uri uri = FileProvider.getUriForFile(DetailActivity.this, getString(R.string.authority), file);
    share.setPackage("com.whatsapp");
    // Add the URI to the Intent.
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    PackageManager packageManager = getPackageManager();
    if (share.resolveActivity(packageManager) != null) {
        startActivity(share);
        startActivity(Intent.createChooser(share, "Share to"));

    } else {
        alertForApp(getString(R.string.install_whatsapp), "com.whatsapp");
    }

    // Broadcast the Intent.
}
Soonsooner answered 8/10, 2019 at 5:7 Comment(2)
<string name="authority" translatable="false">//packagename//.fileProvider</string>Soonsooner
Can you please elaborate a bit how the code solve the problem? Also could you please add your code into the answer by editing it, instead of adding comments?Cherimoya

© 2022 - 2024 — McMap. All rights reserved.