Mic*_*ach 4 android telephony telephonymanager
我打算编写与Phone和Direct SIM写相关的测试.
如果所需的API未在TelephonyManager中公开但作为私有API存在PhoneBase.java,PhoneFactory.java或者CommandInterface.java?
具体来说,我的问题是:
PhoneFactory.getDefaultPhone()?CommandsInterface(例如:) 的替代方案是什么CommandsInterface mCmdIf = ((PhoneBase)mPhone).mCM?提前谢谢,
Micha
你可以用java reflection.
这是我如何访问com.android.internal.telephony.ITelephony类的方法 来阻止来电...
private void endCall() throws Exception {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Class<?> c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony telephonyService = (ITelephony) m.invoke(tm);
telephonyService.silenceRinger();
telephonyService.endCall();
Toast.makeText(context, "Call Ended !", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2992 次 |
| 最近记录: |