2011-05-31 15 views
3

可能重複:
How to make a phone call in android and come back to my activity when the call is done?返回到應用的通話結束後

呼叫正在從應用程序通過startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phNo)));啓動。通話結束後,我不會回到應用程序,而是回到手機的桌面。

我在做什麼錯?是否有可能返回到已發起呼叫的應用程序?我不確定Android是否允許這樣做。

編輯: 代碼添加

@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 
+1

你能提供樣本代碼嗎? – 2011-05-31 14:38:45

+0

我相信我最近看到這個問題,有人建議添加一個呼叫監聽器,一旦呼叫狀態改變,他們重新開始他們的活動。不確定,但我會看看我能否爲你找到它。 – DustinRiley 2011-05-31 14:46:17

+0

@Deepak我引用的代碼基本上都是代碼。我會在一秒鐘內添加它。 – sandalone 2011-05-31 18:13:40

回答

2

後啓動電話有一個監聽器一看,完成呼叫活動,它會回重定向到最後活動(你的應用程序)。這裏是一些示例代碼的鏈接(這是西班牙語,但至少應該能夠編碼):Returning to App After Phone Call

-1

你不能

有兩種方法來實例化一個電話。您可以使用電話號碼作爲網址(如您所做的)或android.intent.action.DIAL,並將電話號碼作爲網址(再次)發送android.intent.action.CALL意圖。這兩個都會啓動手機應用程序,它不會自動將控制權交還給您的應用程序。

有以下網址

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

感謝 迪帕克

+0

對不起,但這是不正確的。如果你看到答案,多人做了它,併發布如何做到這一點。 – DustinRiley 2011-05-31 14:53:11

+0

信息不正確。 – Brett 2013-07-23 18:29:14

相關問題