Last active
May 4, 2021 03:50
-
-
Save chethann/bd09b2ca4dfc0aab546cda1b9640d8a0 to your computer and use it in GitHub Desktop.
Sample code to create WebResourceResponse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public WebResourceResponse getWebResourceResponseFromAsset(String assetPath, String mimeType, String encoding) throws IOException{ | |
InputStream inputStream = getActivity().getAssets().open(assetPath); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
int statusCode = 200; | |
String reasonPhase = "OK"; | |
Map<String, String> responseHeaders = new HashMap<String, String>(); | |
responseHeaders.put("Access-Control-Allow-Origin", "*"); | |
return new WebResourceResponse(mimeType, encoding, statusCode, reasonPhase, responseHeaders, inputStream); | |
} | |
return new WebResourceResponse(mimeType, encoding, inputStream); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment