Sdílet prostřednictvím


URLConnection.Connect Method

Definition

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

[Android.Runtime.Register("connect", "()V", "GetConnectHandler")]
public abstract void Connect ();
[<Android.Runtime.Register("connect", "()V", "GetConnectHandler")>]
abstract member Connect : unit -> unit
Attributes

Exceptions

if an error occurs while connecting to the resource.

Remarks

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

If the connect method is called when the connection has already been opened (indicated by the connected field having the value true), the call is ignored.

URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.

Java documentation for java.net.URLConnection.connect().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to