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

第 117 章 网络

目录

117.1. Wifi 配置
117.2. OkHttp - An HTTP & HTTP/2 client for Android and Java applications
117.2.1. Gradle
117.2.2. AndroidManifest.xml 开启网络访问权限
117.2.3. okhttp 默认是 HTTPS 开启 HTTP
117.2.4. 连接池
117.2.5. GET
117.2.6. POST
117.2.7. HTTP PUT 请求
117.2.8. http header 相关设置
117.2.9. HTTP Base Auth
117.2.10. HttpUrl.Builder 组装 URL 地址参数
117.2.11. Android Activity Example
117.2.12. Android Oauth2 + Jwt example
117.2.13. HTTP/2
117.2.14. 异步更新 UI
117.2.15. SSE 客户端
117.2.16. WebSocket Client

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