Share text intent prefilled phone 数字问题
Share text intent prefilled phone number issue
已编写以下代码以在 android 中共享文本。我面临的问题是在短信应用程序中预填 phone 号码。
public static void shareText(final String extraText, final String extraEmail, final String phoneNumber) {
Intent textShareIntent = new Intent(android.content.Intent.ACTION_SEND);
textShareIntent.setType("text/plain");
if (null != extraText) {
textShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, extraText);
}
if (null != extraEmail) {
textShareIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{extraEmail});
}
if (null != phoneNumber) {
textShareIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, new String[]{phoneNumber});
}
startActivity(Intent.createChooser(textShareIntent, "Share via"));
}
如果我没记错的话,您正在寻找的场景是您在屏幕上提供发送消息(来自 WhatsApp 或 SMS)的选项,如果是 SMS,则必须预先填写号码。据我所知和研究,到目前为止,您不能将这两种功能集成在一起,因为 SMS 是移动设备中的标准协议,而 WhatsApp 等其他消息服务则不是(我的意思是它们不支持查找 SMS 协议 An example of messaging app) . What all you can give to give option for SMS where you can open SMS supporting app where in it prefills the number(which is what you require) and messaging which will option other options where in it will open other messaging application(WhatsApp, Telegram). check this
已编写以下代码以在 android 中共享文本。我面临的问题是在短信应用程序中预填 phone 号码。
public static void shareText(final String extraText, final String extraEmail, final String phoneNumber) {
Intent textShareIntent = new Intent(android.content.Intent.ACTION_SEND);
textShareIntent.setType("text/plain");
if (null != extraText) {
textShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, extraText);
}
if (null != extraEmail) {
textShareIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{extraEmail});
}
if (null != phoneNumber) {
textShareIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, new String[]{phoneNumber});
}
startActivity(Intent.createChooser(textShareIntent, "Share via"));
}
如果我没记错的话,您正在寻找的场景是您在屏幕上提供发送消息(来自 WhatsApp 或 SMS)的选项,如果是 SMS,则必须预先填写号码。据我所知和研究,到目前为止,您不能将这两种功能集成在一起,因为 SMS 是移动设备中的标准协议,而 WhatsApp 等其他消息服务则不是(我的意思是它们不支持查找 SMS 协议 An example of messaging app) . What all you can give to give option for SMS where you can open SMS supporting app where in it prefills the number(which is what you require) and messaging which will option other options where in it will open other messaging application(WhatsApp, Telegram). check this