2015-10-07 45 views
0

我正在使用sinch調用服務的應用程序調用它的工作正常,只要我在onSinchServiceConnected()中使用int和字符串作爲callId但如果用戶名有特殊字符,則不會調用。Android Sinch服務不支持CallId中的特殊字符

AppConstant.CALL_ID = mCallId = getIntent().getStringExtra(
      SinchService.CALL_ID);//Contain Special characters. 

//And in onServiceConnected() use 

    Call call = getSinchServiceInterface().getCall(mCallId); 

回答

0

我不能得到你的問題很好,但我認爲這是解決這個樣子。 您可以使用mCallId的編碼和解碼來完成此操作。 而placeing通話編碼CALLID

public String Encode(String str) { 
    byte[] data = null; 
    try { 
     data = str.getBytes("UTF-8"); 
    } catch (UnsupportedEncodingException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    String base64 = Base64.encodeToString(data, Base64.DEFAULT); 
    return base64; 
} 

和使用呼叫ID爲

Call call = getSinchServiceInterface().callUser(Encode(name)); 

和接收呼叫

public String decode(String str) { 
    byte[] data = Base64.decode(str, Base64.DEFAULT); 
    String text = null; 
    try { 
     text = new String(data, "UTF-8"); 
    } catch (UnsupportedEncodingException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    return text; 
} 

,並用它

String userEncoded = call.getRemoteUserId(); 
String decodedUserName = decode(userEncoded);