3

Possible Duplicate:
How to make a phone call in android and come back to my activity when the call is done?

The call is being initiated from the app via startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phNo)));. After the call ends, I do not return to the app, but to the phone's desktop.

What am I doing wrong? Is it possible to return to the app that has initiated the call? I am not sure if this is allowed in Android.

EDIT: Code added

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

switch ((int) id) {
    case 0:
        try {
            TextView txtCallDisp = (TextView) findViewById(R.id.itmDdd);
            startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phNo)));
        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (Exception ee) {
            ee.printStackTrace();
        }
        break;
    //... other switch statements
Community
  • 1
  • 1
sandalone
  • 41,141
  • 63
  • 222
  • 338
  • I believe I saw this asked recently and someone suggested adding a call listener and once the call state changed they restarted their activity. Not sure but I'll see if I can find it for you. – DustinRiley May 31 '11 at 14:46
  • @Deepak The code I cited is basically all the code. I will add it in a sec. – sandalone May 31 '11 at 18:13

2 Answers2

2

After you start the phone call have a listener, finish the call activity, and it will redirect back to the last activity (your app). Here is a link to some sample code (it's in spanish but you should be able to make out the code at least): Returning to App After Phone Call

DustinRiley
  • 555
  • 6
  • 15
-1

You can't

There are two ways to instantiate a phone call. You can fire off an android.intent.action.CALL Intent with the phone number as the URL (as you're doing) or android.intent.action.DIAL with the phone number as the URL (again). Both of these start the phone app thingy and it won't automatically return control to your app.

have a look on the following URL

How to make a phone call in android and come back to my activity when the call is done?

Thanks Deepak

Community
  • 1
  • 1
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243