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

第 11 章 网络

目录

11.1. Wifi 配置
11.2. OkHttp - An HTTP & HTTP/2 client for Android and Java applications
11.2.1. Gradle
11.2.2. AndroidManifest.xml 开启网络访问权限
11.2.3. okhttp 默认是 HTTPS 开启 HTTP
11.2.4. 连接池
11.2.5. GET
11.2.6. POST
11.2.7. HTTP PUT 请求
11.2.8. http header 相关设置
11.2.9. HTTP Base Auth
11.2.10. HttpUrl.Builder 组装 URL 地址参数
11.2.11. Android Activity Example
11.2.12. Android Oauth2 + Jwt example
11.2.13. HTTP/2
11.2.14. 异步更新 UI
11.2.15. SSE 客户端
11.2.16. WebSocket Client

11.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);
                }
            }
        });