Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 120 章 网络

目录

120.1. Wifi 配置
120.2. OkHttp - An HTTP & HTTP/2 client for Android and Java applications
120.2.1. Gradle
120.2.2. AndroidManifest.xml 开启网络访问权限
120.2.3. okhttp 默认是 HTTPS 开启 HTTP
120.2.4. 连接池
120.2.5. GET
120.2.6. POST
120.2.7. HTTP PUT 请求
120.2.8. http header 相关设置
120.2.9. HTTP Base Auth
120.2.10. HttpUrl.Builder 组装 URL 地址参数
120.2.11. Android Activity Example
120.2.12. Android Oauth2 + Jwt example
120.2.13. HTTP/2
120.2.14. 异步更新 UI
120.2.15. SSE 客户端
120.2.16. WebSocket Client

120.1. Wifi 配置

方法一

	
        context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));	
	
	

方法二

		
        Button buttonWifi = root.findViewById(R.id.buttonWifi);
        buttonWifi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                ComponentName componentName = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings");
                intent.setComponent(componentName);
                ResolveInfo resolveInfo = getActivity().getPackageManager().resolveActivity(intent, 0);
                if (resolveInfo != null) {
                    startActivity(intent);
                }
            }
        });