0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android webview proxyについて

Posted at

結論

設定可能です。

やりかた

・以下プロキシの設定を行うことで、webviewからのアクセスがproxy経由になります。
※ proxyは無料で提供されているものを使用

    public class MainActivity extends Activity {
    
        @SuppressLint("SetJavaScriptEnabled")
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            Properties prop = System.getProperties();
            prop.setProperty("proxySet", "true");
            prop.setProperty("proxyHost", "146.120.176.60");
            prop.setProperty("proxyPort", "54766");
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            WebView  myWebView = (WebView)findViewById(R.id.webView1);
            myWebView.setWebViewClient(new WebViewClient());
            myWebView.loadUrl("https://www.ugtop.com/spill.shtml");
            myWebView.getSettings().setJavaScriptEnabled(true);
        }
    }

備考

アプリをバックグラウンドにした場合でも、端末の別ブライザには影響を与えないようだ。
(アクセス元IPがproxyのIPではなかったため。)

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?