2017-01-03 40 views
0

我有一個簡單的android應用程序,我正在測試以進行VOIP呼叫。在佈局我有一個TextView如圖使用Android提示作爲默認電話或電子郵件

<org.myapp.ui.AddressText 
     android:id="@+id/address" 
     android:background="@color/colorF" 
     android:textColorHint="@color/colorI" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:paddingLeft="20dp" 
     android:paddingRight="5dp" 
     android:layout_toLeftOf="@id/erase" 
     android:layout_centerVertical="true" 
     android:selectAllOnFocus="false" 
     android:hint=" [email protected]" 
     android:clickable="false" 
     android:editable="false" 
     android:cursorVisible="false" 
     android:focusableInTouchMode="false" 
     android:focusable="false" 
     android:textIsSelectable="false" 
     android:visibility="visible" 
     android:inputType="phone" /> 

</RelativeLayout> 

我也有一個呼叫按鈕,鏈接到的TextView 我想,當用戶按下呼叫按鈕,在不改變SIP地址,應用程序應該自動拾取默認(提示)SIP地址和撥號。可能嗎?

我的意圖函數如下; private AddressText mAddress;

public void OutgoingCall(Intent intent) { 

    if (intent != null && intent.getData() != null) { 
     String scheme = intent.getData().getScheme(); 
     if (scheme.startsWith("imto")) { 

      mAddress.setText("sip:" + intent.getData().getLastPathSegment()); 
     } else if (scheme.startsWith("call") || scheme.startsWith("sip")) { 
      mAddress.setText(intent.getData().getSchemeSpecificPart()); 
     } else { 
      Uri contactUri = intent.getData(); 
      String address = ""; 
      if(address != null) { 
       mAddress.setText(address); 
      } else { 

      //else statement 
      } 
     } 

     mAddress.clearDisplayedName(); 
     intent.setData(null); 

     myPhoneManager.getInstance().newOutgoingCall(mAddress); 
    } 
+0

你試過'getHint()''TextView'類的API? – AADProgramming

回答

1
Uri number = Uri.parse("tel:" + addressEditText.getHint()); 
Intent callIntent = new Intent(Intent.ACTION_DIAL, number); 
startActivity(callIntent); 
0

使用getHint()方法得到的結果是返回一個字符序列,並觸發一個意圖調用號碼。

1

您可以使用類似: -

Intent callIntent = new Intent(Intent.ACTION_DIAL); 
callIntent.setData(Uri.parse("tel:" + addressText.getHint())); 
startActivity(callIntent); 
+0

myPhoneManager.getInstance()。newOutgoingCall(mAddress.getText()); – Paras

相關問題