in Android/app/src/main/java/com/example/samplestickerapp/AddStickerPackActivity.java [29:53]
protected void addStickerPackToWhatsApp(String identifier, String stickerPackName) {
try {
//if neither WhatsApp Consumer or WhatsApp Business is installed, then tell user to install the apps.
if (!WhitelistCheck.isWhatsAppConsumerAppInstalled(getPackageManager()) && !WhitelistCheck.isWhatsAppSmbAppInstalled(getPackageManager())) {
Toast.makeText(this, R.string.add_pack_fail_prompt_update_whatsapp, Toast.LENGTH_LONG).show();
return;
}
final boolean stickerPackWhitelistedInWhatsAppConsumer = WhitelistCheck.isStickerPackWhitelistedInWhatsAppConsumer(this, identifier);
final boolean stickerPackWhitelistedInWhatsAppSmb = WhitelistCheck.isStickerPackWhitelistedInWhatsAppSmb(this, identifier);
if (!stickerPackWhitelistedInWhatsAppConsumer && !stickerPackWhitelistedInWhatsAppSmb) {
//ask users which app to add the pack to.
launchIntentToAddPackToChooser(identifier, stickerPackName);
} else if (!stickerPackWhitelistedInWhatsAppConsumer) {
launchIntentToAddPackToSpecificPackage(identifier, stickerPackName, WhitelistCheck.CONSUMER_WHATSAPP_PACKAGE_NAME);
} else if (!stickerPackWhitelistedInWhatsAppSmb) {
launchIntentToAddPackToSpecificPackage(identifier, stickerPackName, WhitelistCheck.SMB_WHATSAPP_PACKAGE_NAME);
} else {
Toast.makeText(this, R.string.add_pack_fail_prompt_update_whatsapp, Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "error adding sticker pack to WhatsApp", e);
Toast.makeText(this, R.string.add_pack_fail_prompt_update_whatsapp, Toast.LENGTH_LONG).show();
}
}