I am trying to develop something similar to AutoAnswer, but it also freezes automatically when a broadcast receiver is notified. I spent all day reading another stackoverflow question on this issue, and it seems that MODIFY_PHONE_STATE
permission MODIFY_PHONE_STATE
limited by system applications, however some posts say that using endCall (); does not require this permission.
My question has two parts :
This is what my file tree in netbeans looks like:
And this is the code that works in my translator. This has been published many times here before as a solution to this problem, but I still can't get it to work: /
ITelephony telephonyService; TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try { 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) {
Looking through the logs, I see this error:
[PhoneIntfMgr] CMD_END_CALL: no call to hang up
EDIT: I am new to Android development and cannot find console output for Android applications - for example, to call e.printStackTrace (), but I have a toast displaying some text inside the catch block, like this:
catch (Exception e) { Toast toast = Toast.makeText(context, "IN CATCH BLOCK ", Toast.LENGTH_LONG); toast.show(); e.printStackTrace(); }
But nothing is displayed on the screen.
source share