Skip to content Skip to sidebar Skip to footer

Caused By: Java.lang.illegalargumentexception: Host Name May Not Be Null

I am using four Strings in my code. The first String contains 'http://', the second String contains user host URL (entered by user), the third contains '/musics/a.mp3' and the four

Solution 1:

If the host part of the URL comes from the user, you must validate it before using it to construct a URL.

Don't call new JSONAsyncTask().execute(fourth); if second is null.

Solution 2:

If you're calling etTextToSave.getText() in onCreate(), the returned text will be whatever there's by default in the layout and not what was entered by the user.

The code doesn't show if you're using an onclick listener or similar but if you are, move the getText() to the click handler.

Post a Comment for "Caused By: Java.lang.illegalargumentexception: Host Name May Not Be Null"