How to handle ports in URI.Builder class in Android

A.K.

When testing my android app in development environment, I want to connect to a server running on port 9000. But when I supply the port to Builder.authority("localhost:9000"), it does not work. On the other hand if I create the same URL by hand like new URL("localhost:9000"), it works fine.

What is the alternative?

Madhukar Hebbar

Uri.Builder will encode your URL so that ':' is replaced by %3 .

To prevent encoding use the encoded versions of builder functions:

String host = "localhost:9000";
Uri.Builder builder = new Uri.Builder();
builder.encodedAuthority(host);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

URI builder in Android, odd URL

From Dev

How to reregister for IO Completion ports for a handle

From Java

Use URI builder in Android or create URL with variables

From Dev

Android URI Class - What is it used for?

From Dev

How to show alertdialog from another class and handle it in Current Activity(Android)

From Dev

How are ports and URI schemes handled by a tcp/ip server?

From Dev

How to handle Retrofit RestAdapter.Builder() Exceptions?

From Dev

How to handle content:// Uri in order to open a file

From Dev

How to handle several ports of my own GitHub project?

From Dev

How to replace the Laravel Builder class

From Dev

How to import android.support.v7.app.NotificationCompat.Builder class in Android Studio

From Dev

How to import android.support.v7.app.NotificationCompat.Builder class in Android Studio

From Dev

URI Builder result has an unexpected colon in it (Android Programming)

From Dev

Android Uri.Builder using "/" instead of "//" after scheme

From Dev

Android: Create a URL using Uri.Builder().build() with port numbers

From Dev

How to Handle NullPointerException in android?

From Dev

How to handle NotificationBar in android

From Dev

how to handle redirect_uri_mismatch error when Android app obtains offline access for Web back-end?

From Dev

How to handle a vector of template class?

From Dev

How to handle class variable without $this?

From Dev

How to handle, if .class contain password?

From Dev

URI for reference a Dao class in an Android app

From Dev

Preserve arguments in uri builder

From Dev

Java Use URI builder?

From Dev

How to set string for uri in android?

From Dev

How do I handle ampersand encoding in Report Builder?

From Dev

How to handle routes in back-end with Express and React as UI builder

From Dev

How to create and config an inner builder class with spring

From Dev

How to check for invalid inputs in the Builder pattern class?

Related Related

  1. 1

    URI builder in Android, odd URL

  2. 2

    How to reregister for IO Completion ports for a handle

  3. 3

    Use URI builder in Android or create URL with variables

  4. 4

    Android URI Class - What is it used for?

  5. 5

    How to show alertdialog from another class and handle it in Current Activity(Android)

  6. 6

    How are ports and URI schemes handled by a tcp/ip server?

  7. 7

    How to handle Retrofit RestAdapter.Builder() Exceptions?

  8. 8

    How to handle content:// Uri in order to open a file

  9. 9

    How to handle several ports of my own GitHub project?

  10. 10

    How to replace the Laravel Builder class

  11. 11

    How to import android.support.v7.app.NotificationCompat.Builder class in Android Studio

  12. 12

    How to import android.support.v7.app.NotificationCompat.Builder class in Android Studio

  13. 13

    URI Builder result has an unexpected colon in it (Android Programming)

  14. 14

    Android Uri.Builder using "/" instead of "//" after scheme

  15. 15

    Android: Create a URL using Uri.Builder().build() with port numbers

  16. 16

    How to Handle NullPointerException in android?

  17. 17

    How to handle NotificationBar in android

  18. 18

    how to handle redirect_uri_mismatch error when Android app obtains offline access for Web back-end?

  19. 19

    How to handle a vector of template class?

  20. 20

    How to handle class variable without $this?

  21. 21

    How to handle, if .class contain password?

  22. 22

    URI for reference a Dao class in an Android app

  23. 23

    Preserve arguments in uri builder

  24. 24

    Java Use URI builder?

  25. 25

    How to set string for uri in android?

  26. 26

    How do I handle ampersand encoding in Report Builder?

  27. 27

    How to handle routes in back-end with Express and React as UI builder

  28. 28

    How to create and config an inner builder class with spring

  29. 29

    How to check for invalid inputs in the Builder pattern class?

HotTag

Archive