如何在Android上发送虚假来电广播
我正在尝试发送广播来模拟来电。 我在 AndroidManifest.xml 文件中添加了权限,
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
当我尝试运行该程序时,手机会重新启动。(模拟器也是如此)。
Intent intent = new Intent();
intent.setAction("android.intent.action.PHONE_STATE");
intent.putExtra(TelephonyManager.EXTRA_STATE, TelephonyManager.CALL_STATE_RINGING);
intent.putExtra("EXTRA_INCOMING_NUMBER", "923982398");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendBroadcast(intent);
I am trying to send a broadcast to simulate an incoming call.
I added the permission in AndroidManifest.xml file,
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
When I try to run the program, the phone reboots.(Emulator too).
Intent intent = new Intent();
intent.setAction("android.intent.action.PHONE_STATE");
intent.putExtra(TelephonyManager.EXTRA_STATE, TelephonyManager.CALL_STATE_RINGING);
intent.putExtra("EXTRA_INCOMING_NUMBER", "923982398");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendBroadcast(intent);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能是错的,因为我在文档中找不到任何内容,但我想说不可能“欺骗”来电铃声广播。几乎可以肯定它被保留为“仅限系统”。
想想看 - 如果应用程序可以做到这一点,它可能只会导致“恶作剧”而不是任何恶意,但这不是我希望在我的手机上发生的事情。
创建您自己的“电话铃声”操作以用于测试目的,并让您的 BroadcastReceiver 监听它。当您要发布应用程序时,只需更改 BroadcastReceiver 的意图过滤器即可侦听真正的意图过滤器。
I may be wrong as I can't find anything in the docs but I'd say it's not possible to 'spoof' a call ringing broadcast. It's almost certainly reserved as 'system only'.
Think about it - if apps could do this, it may simply result in 'mischief' rather than anything malicious but it isn't something that I'd like to happen on my phone.
Create your own 'phone ringing' action to use for testing purposes and have your BroadcastReceiver listen for it. When you come to release the app then simply change the BroadcastReceiver's intent filter to listen for the real one.
我从游戏商店下载了一些假的来电应用程序并进行了测试。
我发现该应用程序引发了一个事件,该事件在锁定屏幕顶部显示前面提到的 GUI,并使用 ContentResolver 的插入方法将条目添加到调用日志中。
该应用程序不使用内置调用(广播)机制。它只是在屏幕上伪造 GUI 并播放默认铃声/振动。
据我所知,我认为不可能伪造来电铃声广播
I Downloaded some of the fake Caller Apps from play store and tested them.
I found that the App Raises an Event which displays the pre-mentioned GUI on the Top of Lock Screen and adds the entry into call logs using the insert method of ContentResolver.
The app does not use the inbuild Calling (Broadcast) mechanism. it just fakes the GUI on the Screen and plays the Default Ringtone/Vibration.
As per my Knowledge, I think it is not possible to fake a call ringing broadcast