Android APIs
public class

WebResourceResponse

extends Object
java.lang.Object
   ↳ android.webkit.WebResourceResponse

Class Overview

Encapsulates a resource response. Applications can return an instance of this class from shouldInterceptRequest(WebView, String) to provide a custom response when the WebView requests a particular resource.

Summary

Public Constructors
WebResourceResponse(String mimeType, String encoding, InputStream data)
Constructs a resource response with the given MIME type, encoding, and input stream.
Public Methods
InputStream getData()
Gets the input stream that provides the resource respone's data.
String getEncoding()
Gets the resource response's encoding.
String getMimeType()
Gets the resource response's MIME type.
void setData(InputStream data)
Sets the input stream that provides the resource respone's data.
void setEncoding(String encoding)
Sets the resource response's encoding, for example UTF-8.
void setMimeType(String mimeType)
Sets the resource response's MIME type, for example text/html.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public WebResourceResponse (String mimeType, String encoding, InputStream data)

Added in API level 11

Constructs a resource response with the given MIME type, encoding, and input stream. Callers must implement InputStream.read(byte[]) for the input stream.

Parameters
mimeType the resource response's MIME type, for example text/html
encoding the resource response's encoding
data the input stream that provides the resource response's data

Public Methods

public InputStream getData ()

Added in API level 11

Gets the input stream that provides the resource respone's data.

Returns
  • the input stream that provides the resource response's data

public String getEncoding ()

Added in API level 11

Gets the resource response's encoding.

Returns
  • the resource response's encoding

public String getMimeType ()

Added in API level 11

Gets the resource response's MIME type.

Returns
  • the resource response's MIME type

public void setData (InputStream data)

Added in API level 11

Sets the input stream that provides the resource respone's data. Callers must implement InputStream.read(byte[]).

Parameters
data the input stream that provides the resource response's data

public void setEncoding (String encoding)

Added in API level 11

Sets the resource response's encoding, for example UTF-8. This is used to decode the data from the input stream.

Parameters
encoding the resource response's encoding

public void setMimeType (String mimeType)

Added in API level 11

Sets the resource response's MIME type, for example text/html.

Parameters
mimeType the resource response's MIME type