如何使用URL进行URL编码?

时间:2018-02-22 09:10:48

标签: android android-volley url-encoding getmethod

我使用的是一种格式的网址。但是当我在Google中输入它并按下输入时,它将转换为另一种格式。

下面是我的原始网址

'https://translation.googleapis.com/language/translate/v2?q=hai basha.how are  you&target=te&key={YOUR_API_KEY}'
下面的

是我编码的网址

'https://translation.googleapis.com/language/translate/v2?q=hai%20basha.how%20are%20you&target=te&key={YOUR_API_KEY}'

如何在我的代码中实现这一点。实际上它是GET方法。

1 个答案:

答案 0 :(得分:-1)

您可以使用String.replace方法将字符更改为各自的特殊字符表示法。并通过获取或发布或任何你想要的方式拨打电话。