基于Intent的WhatsApp图片分享:生物识别认证引发的问题
问题:开启生物识别锁的WhatsApp无法接收Intent分享的图片
在Android应用中,通过Intent向开启生物识别锁的WhatsApp分享图片时,仅能打开指定聊天窗口,但图片无法加载或发送,无待发送附件显示。该功能1-2周前可正常使用,推测是WhatsApp端发生变更导致。
相关代码
private void openWhatsAppAndTelegram(String packageName, SecureRentTaking_GetterSetter activity, String caption) { File appFolderLocation = new File(cachePath, OUTPUT_RENT_RECEIPT_PNG_NAME); Uri contentUri = FileProvider.getUriForFile(activity.mContext, BuildConfig.APPLICATION_ID.concat(".provider"), appFolderLocation); if (contentUri == null) { In_Place.toastHelper.toastErrorMsg("File Not Present"); } else { String toNumber = getFormattedNumber(activity.getTenantContactNumber());//getFormattedWatsAppNumber(activity.getTenantContactNumber()); toNumber = toNumber.replace("+", "").replace(" ", ""); // E164 format without '+' sign Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, caption); sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri); sendIntent.setDataAndType(contentUri, activity.mContext.getContentResolver().getType(contentUri)); sendIntent.putExtra("jid", toNumber + "@s.whatsapp.net"); //phone number without "+" prefix sendIntent.setPackage(packageName); //com.whatsapp //com.whatsapp.w4b sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (sendIntent.resolveActivity(activity.mContext.getPackageManager()) != null) { activity.mContext.startActivity(Intent.createChooser(sendIntent, "Choose an app")); } else { In_Place.toastHelper.toastErrorMsg("App is not Installed"); // WhatsApp is not installed, handle accordingly // You can prompt the user to install WhatsApp or use a different method to send messages } } }
现有进展
已发现同类未解决问题:当WhatsApp开启应用锁时,分享内容到WhatsApp失败。
内容的提问来源于stack exchange,提问作者Hitesh Verma
相关产品推荐
相关产品推荐

