Post Reply

How to interrupt ACTION_CALL

5th January 2011, 07:04 PM   |  #1  
OP Junior Member
Thanks Meter: 0
2 posts
Join Date:Joined: Dec 2010
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!
6th January 2011, 10:03 AM   |  #2  
Junior Member
Thanks Meter: 0
2 posts
Join Date:Joined: 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)
7th January 2011, 02:15 PM   |  #3  
OP Junior Member
Thanks Meter: 0
2 posts
Join Date:Joined: 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?
8th January 2011, 08:28 PM   |  #4  
Thanks Meter: 7
55 posts
Join Date:Joined: 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.
Post Reply Subscribe to Thread

activity, interrupt activity
Previous Thread Next Thread
Thread Tools
Display Modes

Top Threads in Android Software Development by ThreadRank