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

第 70 章 网络

目录

70.1. Wifi 配置
70.2. WI-FI 与 蜂窝网络 信号强度检测
70.3. OkHttp - An HTTP & HTTP/2 client for Android and Java applications
70.3.1. Gradle
70.3.2. AndroidManifest.xml 开启网络访问权限
70.3.3. okhttp 默认是 HTTPS 开启 HTTP
70.3.4. 连接池
70.3.5. HttpUrl
70.3.6. GET
70.3.7. POST
70.3.8. HTTP PUT 请求
70.3.9. http header 相关设置
70.3.10. HTTP Base Auth
70.3.11. HttpUrl.Builder 组装 URL 地址参数
70.3.12. Android Activity Example
70.3.13. Android Oauth2 + Jwt example
70.3.14. HTTP/2
70.3.15. 异步更新 UI
70.3.16. SSE 客户端
70.3.17. WebSocket Client
70.3.18. EventListener
70.3.19. 文件下来
70.4. Retrofit - https://github.com/square/retrofit
70.4.1. Gradle 依赖
70.4.2. Authorization 头

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