Nevaeh
Nevaeh

Reputation: 1569

How to disable web security when using angularjs in android webview?

I'm creating an android application in which i want to use angularjs for displaying html contents in my webview.Its not working normally.I just realized that i should disable web security option since it worked in chrome when i did that.Could anyone tell me how to do that ??

Upvotes: 5

Views: 5389

Answers (2)

MantasG
MantasG

Reputation: 233

webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);

These lines enable cross origin requests for file:// protocol but it requires API level at least 16.

Upvotes: 5

Nevaeh
Nevaeh

Reputation: 1569

These two lines worked for me...

wv.getSettings().setAllowFileAccessFromFileURLs(true);
wv.getSettings().setAllowUniversalAccessFromFileURLs(true);

Upvotes: -1

Related Questions