Android Sample 之 BasicNetworking
来源:互联网 发布:黎巴嫩真主党 知乎 编辑:程序博客网 时间:2024/06/05 02:26
This sample demonstrates how to use the ConnectivityManager
to determine if the device has an active network connection, and if so, retrieve the connection type.
ConnetivityManager
Class OverView
Class that answers queries about the state of network connectivity. It also notifies applications when network connectivity changes. Get an instance of this class by calling Context.getSystemService(Context.CONNECTIVITY_SERVICE)
.
The primary responsibilities of this class are to:
- Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)
- Send broadcast intents when network connectivity changes
- Attempt to "fail over" to another network when connectivity to a network is lost
- Provide an API that allows applications to query the coarse-grained or fine-grained state of the available networks
- Provide an API that allows applications to request and select networks for their data traffic
这个 Sample 展示 怎么样使用ConnectivityManager去确定是否设备有一个有效的网络连接,并且如果有一个,返回连接类型。
连接管理类。
类概述
该类回答查询网络连接状态,当网络连接改变时,它也会通知应用程序。通过调用Context.getSystemService(Context.CONNECTIVITY_SERVICE)返回一个实例。
这个类的主要负责:
1.显示网络连接(Wi-Fi, GPRS, UMTS, etc.)
2.当网络连接改变是(发送)广播intents
3.当网络丢失时,试图去(连接)娶她网络
4.提供一个API去允许应用程序查询可用的网络的oarse-grained or fine-grained 状态(oarse-grained or fine-grained 可能表示网络信号的好、坏的吧)
5.提供一个API去允许应用为了他们的数据传输查询和选择一个网络。
- Android Sample 之 BasicNetworking
- Android Sample 之 BasicNetworking
- BasicNetworking
- android sample 之 其他
- Android SDK sample 之 SoftKeyboard 详解
- Android输入法开发之Android SDK Sample—SoftKeyboard
- Android Sample Code之API Demos (Activity一): Hello World
- Android Sample Code之API Demos (Activity五): 背景透明
- 安卓适配之android-percent-support-lib-sample的用法
- Android Sample——UI之ActionBarCompat-Basic学习
- SliverLight 之Sample
- openstack 之 ceilometer: Sample
- Sample之MediaEffects
- Sample之Camera2BasicFragment
- Sample之ShaderCamera_Example
- Sample之Renderscript
- 【计划】Android Sample Codes
- Android导入sample项目
- ZOJ 3802
- 马化腾:明年将专注于开放平台和移动产品
- 免费的javascript富文本编辑器
- 【菜鸟也疯狂UML系列】——面向对象技术
- cobol学习之五简单输入成绩的计算
- Android Sample 之 BasicNetworking
- 蓝桥杯:操作格子(线段树)
- GDI简明入门
- Assignments-Learning Python Chapter 11
- UML九种图
- 二叉树的建立
- 指针复杂声明
- C# Timer定时器的用法(定时器的终止)
- 指定maven本地库的位置