-3

I came across a weird situation. I am trying to a develop a android app which send the user entered data to the web server. I used HttpURLConnection and wrote code. It worked a few days. Now when I try to use that app it doesn't send the data if it contains spaces in between. Also if Genymotion emulator is used then it works fine even though spaces are given. I am not getting an idea of what the problem is. What should i do now??

Krish
  • 3
  • 2
  • 2
    You are no providing any info, have you debugged it? are you sure that is a encoding problem? – Nanoc Oct 30 '15 at 16:05

1 Answers1

0

you simply can't write a space directly in an url.

You have to encode it via %20 ... look here In a URL, should spaces be encoded using %20 or +?

Community
  • 1
  • 1
Stephan Huewe
  • 124
  • 1
  • 7
  • I am sending the data using GET method. First i encoded the strings and then attached them to url. But the app worked for many days before. But now its not working – Krish Oct 30 '15 at 16:17
  • in one of my apps i do the same thing and it is not possible to send spaces directly per GET. I solved the problem by encoding the spaces with %20 which is as far as I know the normal way to do this (via the replace methods for strings) – Stephan Huewe Oct 30 '15 at 16:21
  • I checked the app in a Moto E2 device and it is working but originally I am testing it in Celkon Q54 device where the URL encoder is not working – Krish Nov 02 '15 at 14:21
  • please post some lines of code. maybe this helps. In principle you should look for a solution which works on all devices. Don't care about cases which work for some devices and for others not.Did you test it with or without the replacements of the spaces? – Stephan Huewe Nov 02 '15 at 14:31