I'm trying to develop something similar to AutoAnswer but it also auto hangs up when a broadcast receiver is notified. I've spent all day reading other stackoverflow question on this issue and it seems that the permission MODIFY_PHONE_STATE
is restricted to System Apps, however, some posts said that using endCall(); does not require this permission.
My question has two parts:
- Is
endCall()
still usable? Has it ever been used anywhere in any case since Android 2.3? - If it is, I need help making it work because right now it's not working. I download
ITelephony.aidl
from http://code.google.com/p/autoanswer/source/browse/trunk/src/com/#com/android/internal/telephony and put it in a package. I'm a new user so I can't post images.
This is what my file tree looks like in netbeans:
And this is the code thats running in my broadcastreceiver. It's been posted numerous times here before as a solution to this problem yet 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) {
//TODO: some exception handling
}
Looking through the logs, I see this error:
[PhoneIntfMgr] CMD_END_CALL: no call to hang up
EDIT: I'm brand new to android development and can't seem to find the console output for android apps - like for a call to e.printStackTrace() but I did have Toast display 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 shows up on the screen..