Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,739,332 Members 52,931 Now Online
XDA Developers Android and Mobile Development Forum

How to interrupt ACTION_CALL

Tip us?
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Dec 2010
Default How to interrupt ACTION_CALL

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!
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Dec 2010
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)
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Dec 2010
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?
Thanks Meter 7
Posts: 55
Join Date: Nov 2010
Try the following code:

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

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

But you need to get ITelephony.aidl from Android sources and compile it.
Back-up and restore your data, copy SMS messages and contacts between different phones (Android, J2ME, Windows Mobile, Symbian S60 and UIQ) :
Looking for interesting projects.
activity, interrupt activity
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes