编写了以下代码以在 android 中共享文本。我面临的问题是在短信应用中预填电话号码。
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"));
}