android studio 开发第三方应用,调用ITelephony.aidl删除未接电话通知

Android studio调用ITelephony.aidl,首先要导入ITelephony.aidl文件到工程源码,导入方法参考:http://www.cnblogs.com/daxiaaichihanbaobao/p/4345640.html。
导入完成之后,即可开始引用ITelephony类中的方法。
 
  
private void cancelNotification(){

    TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    Class  c = TelephonyManager.class;
    Method getITelephonyMethod = null;
    try {
        getITelephonyMethod = c.getDeclaredMethod("getITelephony", (Class[])null);
        getITelephonyMethod.setAccessible(true);
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        //ITelephony iTelephony = ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
        ITelephony iTelephony = (ITelephony) getITelephonyMethod.invoke(tm, (Object[])null);
        if (iTelephony != null) {
            iTelephony.cancelMissedCallsNotification();//删除未接来电通知
        } else {
            Log.w("CallLogAdapter", "Telephony service is null, can't call " +
                    "cancelMissedCallsNotification");
        }
    } catch (RemoteException e) {
        Log.e("CallLogAdapter", "Failed to clear missed calls notification due to remote exception");
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

}

参考文档:http://tech.cncms.com/shouji/android/111961.html

http://blog.csdn.net/buleriver/article/details/7624024

你可能感兴趣的:(android studio 开发第三方应用,调用ITelephony.aidl删除未接电话通知)