我想创建IntentChooser
提供仅通过短信或WhatsApp分享文字的提议。
以下是我通过WhatsApp分享的代码:
Intent localIntent = new Intent(Intent.ACTION_SEND);
localIntent.setType("text/plain");
localIntent.setPackage("com.whatsapp");
if (localIntent != null) {
localIntent.putExtra(Intent.EXTRA_TEXT, "Hi there! I'm using this app");
startActivity(Intent.createChooser(localIntent, "Hi there! I'm using this app");
}
我需要添加到此还与SMS共享。我该怎么办?
感谢提前。
答案 0 :(得分:1)
将此用于 Whatsapp 。
try {
startActivity(new Intent(Intent.ACTION_SEND).setType("text/plain").setPackage("com.whatsapp").putExtra(Intent.EXTRA_TEXT, Message));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "Whatsapp have not been installed.", Toast.LENGTH_SHORT).show();
}
和短信。
String number = "12346556"; // The number on which you want to send SMS
startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", number, null)));
或强>
的可能重复