How to interrupt ACTION_CALL

Search This thread

barjebus

New member
Dec 10, 2010
2
0
I'm a new android developer working on an extremely simple app and I just need a quick pointer! My app, once started, needs to call a certain phone number. This part was simple and works fine. However, I need that call to end after a specific amount of time (10 seconds is the number I'd like).

At this point I'm unsure how to proceed. I've tried spawning a thread that simply waits for 10 seconds, and then tries to call finishActivity() on the activity that I originally started. However, I'm assuming that one thread can't control another threads activities, so this clearly doesn't work. I've also tried a few other methods and none of them seem to work, or they simply crash my app.

If someone can even give me just a high level overview of what I need to do that would be great! My next thought is to spawn a timer thread and use RPC to call a function that will activate finishActivity() in the thread that is running the activity.

Any information you guys can provide me with will be fantastic!
 

liquidfer

New member
Dec 20, 2010
2
0
The API won't let you, however, you could try to switch ON airplane mode and the switch it OFF, the inconvenience of this is that all your active connections will be droped (3G, GRPS, Bluetooth, WiFi)
 

barjebus

New member
Dec 10, 2010
2
0
Are you sure its not possible? Using various callbacks I've sent finishActivity() to the action with success. The problem is that there are no callbacks that occur around the time that I want the call to end.

Since it does work with callbacks, I was tempted to have finishActivity() be called when the app is backgrounded. That way after 10 seconds I can just hit the home key and it will close the app down entirely? Not exactly what I want, but could work for now.

Due to the fact that it can be finished during a call back I think it must be possible, I'm just not sure how to go about achieving it. Does anyone have any ideas?
 

rwxer

Senior Member
Nov 16, 2010
55
7
www.bloove.com
Try the following code:

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

Class clazz = Class.forName(tm.getClass().getName());
Method m = clazz.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony it = (ITelephony) m.invoke(tm);
it.endCall();

But you need to get ITelephony.aidl from Android sources and compile it.