当fb-messenger是用户手机中的默认短信客户端应用程序时,用户尝试从我的应用程序发送短信,并且它将启动具有预填充数据的fb-messenger应用程序。到此步骤为止,一切正常,但是当用户按下某些联系人的发送按钮时,它正在发送短信msg,但是对于大多数联系人,该消息在聊天窗口中显示几秒钟,然后消失。基本上对于大多数联系人,fb-messenger的行为均不符合预期,即,它没有发送短信。任何帮助将不胜感激。
这是我的代码
public void sendMessage(String name, String phone,int invitationCode) {
String sms = "Hey "+name+"! Wanna be my friend on xyz? It’s a great new way to chat.\n"+
"Enter invitation code: "+ invitationCode +"\n" +
"\n" +
"https://www.xyz.mobi/getApp";
String smsNumber = String.format("smsto: %s", phone);
// Create the intent.
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setData(Uri.parse(smsNumber));
smsIntent.putExtra("sms_body", sms);
// If package resolves (target app installed), send intent.
if (smsIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(smsIntent);
} else {
Log.d(TAG, "Can't resolve app for ACTION_SENDTO Intent");
}
}