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

第 108 章 网络

目录

108.1. Wifi 配置
108.2. WI-FI 与 蜂窝网络 信号强度检测
108.3. OkHttp - An HTTP & HTTP/2 client for Android and Java applications
108.3.1. Gradle
108.3.2. AndroidManifest.xml 开启网络访问权限
108.3.3. okhttp 默认是 HTTPS 开启 HTTP
108.3.4. 连接池
108.3.5. HttpUrl
108.3.6. GET
108.3.7. POST
108.3.8. HTTP PUT 请求
108.3.9. http header 相关设置
108.3.10. HTTP Base Auth
108.3.11. HttpUrl.Builder 组装 URL 地址参数
108.3.12. Android Activity Example
108.3.13. Android Oauth2 + Jwt example
108.3.14. HTTP/2
108.3.15. 异步更新 UI
108.3.16. SSE 客户端
108.3.17. WebSocket Client
108.3.18. EventListener
108.3.19. 文件下来
108.4. Retrofit - https://github.com/square/retrofit
108.4.1. Gradle 依赖
108.4.2. Authorization 头

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