我想阻止几个号码的来电,因为我想写一个我自己的应用程序.那么我应该使用哪些API?
基本上我想在通话时收到通知,我想比较数字,如果它是我想阻止的,我想要切断电话或将其静音,或者如果可能的话将其静音并记录下来.
我希望阻止一些曲柄调用,所以我需要在android中以编程方式挂断一些调用.
以下片段来自如何在Android中挂断电话?
是否意味着挂断电话的技术会在进一步的Android版本中随时被阻止?
这是否意味着我无法编写应用程序来挂断电话?
我到目前为止挂断的唯一方法是通过Java Reflection完成.由于它不是公共API的一部分,因此您应该小心使用它,而不是依赖它.对Android内部组成的任何更改都将有效地破坏您的应用程序.
当电话铃响时,我设法准备了一项活动.现在我需要知道如何取消这个活动,当我打电话或拒绝电话时.我是否打电话给EXTRA_STATE_IDLE?EXTRA_STATE_OFFHOOK?
有任何想法吗?
<receiver android:name=".IncomingBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
public class IncomingBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
// If an incoming call arrives
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING))
{ //Did my work }
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用反射来访问电话API的一些未发布的功能.目前我无法实例化serviceManager将"电话"服务作为活页夹所需的对象,然后我可以使用该对象来实例化拨打电话,结束通话等所需的电话对象......
目前我打电话的时候
serviceManagerObject = tempInterfaceMethod.invoke(null, new Object[] { new Binder() });
Run Code Online (Sandbox Code Playgroud)
它返回nullPointerException.我相信这与创建一个新的Binder而不是发送适当的粘合剂(我不确定哪个是合适的)有关
public void placeReflectedCall() throws ClassNotFoundException,
SecurityException, NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException,
InstantiationException {
String serviceManagerName = "android.os.IServiceManager";
String serviceManagerNativeName = "android.os.ServiceManagerNative";
String telephonyName = "com.android.internal.telephony.ITelephony";
Class telephonyClass;
Class telephonyStubClass;
Class serviceManagerClass;
Class serviceManagerStubClass;
Class serviceManagerNativeClass;
Class serviceManagerNativeStubClass;
Method telephonyCall;
Method telephonyEndCall;
Method telephonyAnswerCall;
Method getDefault;
Method[] temps;
Constructor[] serviceManagerConstructor;
// Method getService;
Object telephonyObject;
Object serviceManagerObject;
String number = "1111111111";
telephonyClass = Class.forName(telephonyName);
telephonyStubClass = telephonyClass.getClasses()[0];
serviceManagerClass …Run Code Online (Sandbox Code Playgroud) 很长一段时间以来,没有官方的API可以阻止Android上的调用。
针对来电显示和呼叫阻塞应用所做的开发,是使用一些技巧反射,如图所示这里。
似乎没有阻止应用在Android P DP3上运行(已在Pixel 2上进行了测试)。即使是非常流行的应用程序(例如TrueCaller)也无法阻止通话。
我相信这是因为它可能会被正式的API取代,因为有些文章讨论了针对用户的内置呼叫阻止功能:
https://www.gsmarena.com/android_p_may_introduce_stricter_call_blocking-news-29940.php
可以替换它的唯一解决方案是扩展InCallService类,但是这样做还必须使您的应用成为默认的拨号器应用:
除了实现InCallService API外,您还必须在清单中声明一个处理Intent.ACTION_DIAL意图的活动。
不仅如此,一次只能设置一个应用程序,因此用户不能选择多个callerId和/或阻止呼叫的应用程序。
看到我找不到其他选择,现在是请求这种事情的最佳时机,我也在这里提出了要求。
还有拒绝电话的另一种选择吗?
Google现在提供正式功能吗?
我想通过我的应用程序向调制解调器发送命令.有人可以让我知道如何发送AT命令我的应用程序?
我们需要Phone对象发送AT命令吗?
的ATResponseParser类解析使用具有一个移动手持机的移动无线电硬件进行通信的AT命令语法的一部分.实际上,这是非常类似于调制解调器使用的AT命令语法的命令语法,调制解调器是3GPP文档号TS 27.007和相关规范中描述的标准.
我想将以下AT命令发送到Mode.6.5Hangup call +CHUP
表13a:+ CHUP动作命令语法
命令
可能的回应
+CHUP
+CHUP=?
Run Code Online (Sandbox Code Playgroud)
请帮我.
我已经使用以下代码以编程方式断开调用,但它无法正常工作.
private void callDisconnect(){
try{
TelephonyManager manager = (TelephonyManager)this.getSystemService(this.TELEPHONY_SERVICE);
Class c = Class.forName(manager.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony telephony = (ITelephony)m.invoke(manager);
telephony.endcall();
} catch(Exception e){
Log.d("",e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我吗?我需要更改代码还是什么......?