How do I set a proxy in Android phones?

前端 未结 7 430
故里飘歌
故里飘歌 2021-01-31 00:45

Am really wondering how to set a proxy server in android phone like [tattoo] in order to gain access in some private networks

any suggestion would be appreciated ...

7条回答
  •  滥情空心
    2021-01-31 01:18

    I found something here that looks like it might work

    package com.BrowserSettings;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.provider.Settings;
    
    public class BrowserSettingsUI extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            final Button button = (Button) findViewById(R.id.Button01);
            button.setOnClickListener(new Button.OnClickListener() {
                public void onClick(View v) {
                    try {
                        Settings.System.putString(getContentResolver(),  
                Settings.System.HTTP_PROXY, "127.0.0.1:100");//enable proxy
                    }catch (Exception ex){
                    }
                }
            });
    
            final Button button2 = (Button) findViewById(R.id.Button02);
            button2.setOnClickListener(new Button.OnClickListener() {
                public void onClick(View v) {
                    try {
                        Settings.System.putString(getContentResolver(), 
                Settings.System.HTTP_PROXY, "");//disable proxy
                    }catch (Exception ex){
                    }
                }
            });
        }
    }
    

    You must add

    
    

    to your manifest.

提交回复
热议问题