Skip to content
Advertisement

how to handle spaces in url android

i have an error while i tried to run some spaces in url android, this is the code :

JavaScript

as you see.. i have the command for take login validation in strUrlLoginFullpath = strUrlMain+"exl?u="+strUser+"&p="+strPass+"&t=1"; but there’s condition that strUser sometimes containing blank spaces, that can make my program doesn’t run. so how the way to solve this problem.?

Advertisement

Answer

URLEncoder.encode() your URL parameter values so that spaces and other special characters get correctly encoded.

Example:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement