【问题标题】:How to terminate an incoming call within ITelephony如何终止 ITelephony 中的来电
【发布时间】:2017-06-20 10:46:24
【问题描述】:

我正在尝试断开来电但遇到此错误

 public interface ITelephony {
    boolean endCall();
    void answerRingingCall();
    void silenceRinger();
 }
 private void disconnectPhoneItelephony(Context context)
 {
    ITelephony telephonyService;
    TelephonyManager telephony = (TelephonyManager)
            context.getSystemService(Context.TELEPHONY_SERVICE);
    try
    {
    telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        Class<?> c = Class.forName(telephony.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
         telephonyService = (ITelephony) m.invoke(telephony);
        telephonyService.endCall();
    }
    catch (Exception e)
    {
        e.printStackTrace();
        Log.d("error", e.toString());
    }
} 

错误:

(java.lang.ClassCastException:com.android.internal.telephony.ITelephony$Stub$
Proxy cannot be cast to belllab.com.meetingmanager.ITelephony )

【问题讨论】:

  • 检查导入的文件包名和你的。
  • 包名正确
  • 看看你的项目中是否添加了 ITelephony.AIDL 文件?如果你已经添加,那么你的包名必须是包名必须是 com/android/internal/telephony/ITelephony.AIDL
  • 不,我没有添加那个文件
  • 该文件的添加位置以及如何获取该文件

标签: android telephony telephonymanager


【解决方案1】:

如果您在项目中添加了 ITelephony.AIDL 文件?如果不是从here 下载并将其添加到您的项目中。

你必须像这样添加文件

另外,你的包名必须是 com/android/internal/telephony/ITelephony.AIDL:

勾选这个tutorial实现Aidl文件

【讨论】:

  • 现在不工作了,它在代码中给出了电话错误
  • 更新您实现的代码以及日志猫报告。这样我就可以检查了。
  • 它在电话上给出错误,无法解析变量
  • 我只是导入辅助文件
  • @Hami 检查我的更新答案,我已包含实现它的教程。过一遍
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-04
  • 1970-01-01
  • 2017-12-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多