Android模拟器无法发送和接收短信(SmsRetriever,API22错误)
创始人
2024-10-09 06:30:47
0
  1. 确保你的模拟器中安装了Google Play服务和Google Play商店。如果没有,请先下载和安装。

  2. 确认你的应用程序设置了正确定义的权限:



  1. 使用以下代码获取SMS的权限:
SmsRetrieverClient client = SmsRetriever.getClient(this);
Task task = client.startSmsRetriever();
task.addOnSuccessListener(new OnSuccessListener() {
    @Override
    public void onSuccess(Void task) {
        // SMS successfully retrieved
    }
});
task.addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(Exception e) {
        // SMS retriever start failed
    }
});
  1. 如果你的模拟器版本为API Level 22或以下,请确保已安装Google Play服务版本为10.2或以上。可以使用以下代码块检查Google Play服务的版本:
int googlePlayServicesVersion = GoogleApiAvailability.getInstance().getApkVersion(this);
if (googlePlayServicesVersion < 10200000) {
    // Prompt user to update Google Play services
}

如果版本低于10.2,可以通过浏览器下载最新的Google Play服务APK,并在模拟器中手动安装。

  1. 在模拟器中运行telnet localhost 5554,然后运行以下命令以模拟短信:
sms send 1234567890 This is a test message

其中1234567890是目标手机号码,This is a test message是要发送的消息。

如果上述方法仍然无法解决问题,可以尝试使用真实设备测试你的应用程序。

相关内容

热门资讯

反观!wepoker透视脚本是... 反观!wepoker透视脚本是什么,werplan外挂,妙计教程(有挂教学)所有人都在同一条线上,像...
黑科技辅助挂!hhpoker必... 黑科技辅助挂!hhpoker必备开挂,德州透视hhpoker,课程教程(了解有挂)1、hhpoker...
黑科技辅助挂!拱趴大菠萝自动计... 黑科技辅助挂!拱趴大菠萝自动计算机器人,pokemmo免费脚本,教程书教程(有挂教程)拱趴大菠萝自动...
教程辅助挂!wpk私人局辅助是... 教程辅助挂!wpk私人局辅助是真的吗,wepoker软件靠谱么,讲义教程(发现有挂);该软件可以轻松...
2026版教学!德普之星怎么设... 2026版教学!德普之星怎么设置埋牌,wepoker科技辅助器,阶段教程(真实有挂)1、下载好德普之...
更值得关注的是!wpk透视是真... 更值得关注的是!wpk透视是真的吗,pokemmo辅助工具,学习教程(有挂教学)1、起透看视 wpk...
此事引发网友热议!wepoke... 此事引发网友热议!wepoker辅助器下载,hhpoker是内部控制吗,烘培教程(真的有挂)hhpo...
代打辅助挂!epoker有透视... 代打辅助挂!epoker有透视吗,约局吧德州有挂吗,操作教程(有挂教学)1、全新机制【约局吧德州有挂...
于此同时!智星菠萝有挂吗,we... 于此同时!智星菠萝有挂吗,wepoker数据分析,绝活教程(有挂教程)1、实时智星菠萝有挂吗透视辅助...
黑科技攻略!werplan脚本... 黑科技攻略!werplan脚本,pokemmo手机脚本,法门教程(有挂总结)1、首先打开pokemm...