Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gaoyan10/Android-NetworkManager
a library for check network available on Android, which uses ping or request url to get the real network status.
https://github.com/gaoyan10/Android-NetworkManager
Last synced: 3 months ago
JSON representation
a library for check network available on Android, which uses ping or request url to get the real network status.
- Host: GitHub
- URL: https://github.com/gaoyan10/Android-NetworkManager
- Owner: gaoyan10
- Created: 2015-07-09T02:58:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-22T07:02:31.000Z (over 9 years ago)
- Last Synced: 2024-06-25T09:43:10.423Z (5 months ago)
- Language: Java
- Size: 271 KB
- Stars: 6
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android-NetworkManager
a library for check network available on Android, which uses ping or request url to get the real network status.Set Up
---
**Gradle dependency**In your module `build.gradle` add follow
```
dependencies {
compile 'com.yan.netmanager:netmanager:1.2.0'
}
```How to use
---
1. Download this repo and import eclipse as library project. Make your project depend on this project.
2. Optional——Config the library in your application onCreate method or activity onCreate method. Use like below
config ping host and request url(optional, default is "http://www.baidu.com"):```
NetStatusManager.getInstance().config("http://www.baidu.com", "http://www.baidu.com");
```
config use ping or request url(optional, default is request url)
```
NetStatusManager.getInstance().setCheckType(false);
```
config request timeout ( optional, default connect time out is 2000ms and read time out is 2000ms)
```
NetStatusManager.getInstance().configTimeOut(2000, 2000)
```
3. In your activity onResume method, add```
NetStatusManager.getInstance().refreshStatus();
```
4. When you want to access network state, use like below```
NetStatusManager.getInstance().getNetStatus()
```
which return the network status.