当前位置: 首页 > news >正文

专门做三国战纪的网站叫什么意思全球热门网站排名

专门做三国战纪的网站叫什么意思,全球热门网站排名,做网站 内容越多越好,java网站建设技术参数随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666) 相应几乎没有不跟网络打交道的android应用,那么在实际中就需求检测手机是否有网络连接,甚至需要判断是何种方式连接,这样能给…

随时随地技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

相应几乎没有不跟网络打交道的android应用,那么在实际中就需求检测手机是否有网络连接,甚至需要判断是何种方式连接,这样能给用户带来更好的体验和一些使用指导,下面给出一些常用的判断,如果要知道是否有网络、以及是采用wifi连接的还是3G连接的,调用下面对应方法模型就OK了,代码如下:

TestNetworkActivity:

package com.home.testnetwork;import java.util.List;import android.app.Activity;
import android.content.Context;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;public class TestNetworkActivity extends Activity implements OnClickListener {private Button checkBtn;private EditText netText;private EditText wifiText;private EditText net3gText;private EditText gpsText;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);checkBtn = (Button) findViewById(R.id.main_btn_check);checkBtn.setOnClickListener(this);wifiText = (EditText) findViewById(R.id.main_et_wifi);net3gText = (EditText) findViewById(R.id.main_et_3g);gpsText = (EditText) findViewById(R.id.main_et_GPS);netText = (EditText) findViewById(R.id.main_et_net);}/*** 检测网络是否连接* * @return*/private boolean isNetConnected() {ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);if (cm != null) {NetworkInfo[] infos = cm.getAllNetworkInfo();if (infos != null) {for (NetworkInfo ni : infos) {if (ni.isConnected()) {return true;}}}}return false;}/*** 检测wifi是否连接* * @return*/private boolean isWifiConnected() {ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);if (cm != null) {NetworkInfo networkInfo = cm.getActiveNetworkInfo();if (networkInfo != null&& networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {return true;}}return false;}/*** 检测3G是否连接* * @return*/private boolean is3gConnected() {ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);if (cm != null) {NetworkInfo networkInfo = cm.getActiveNetworkInfo();if (networkInfo != null&& networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {return true;}}return false;}/*** 检测GPS是否打开* * @return*/private boolean isGpsEnabled() {LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);List<String> accessibleProviders = lm.getProviders(true);for (String name : accessibleProviders) {if ("gps".equals(name)) {return true;}}return false;}@Overridepublic void onClick(View v) {if (v == checkBtn) {netText.setText(isNetConnected() + "");wifiText.setText(isWifiConnected() + "");net3gText.setText(is3gConnected() + "");gpsText.setText(isGpsEnabled() + "");}}
}


布局xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><Buttonandroid:id="@+id/main_btn_check"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="检测网络" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="网络是否连接:" /><EditTextandroid:id="@+id/main_et_net"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:enabled="false" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="wifi是否连接:" /><EditTextandroid:id="@+id/main_et_wifi"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:enabled="false" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="3G是否连接:" /><EditTextandroid:id="@+id/main_et_3g"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:enabled="false" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="GPS是否打开:" /><EditTextandroid:id="@+id/main_et_GPS"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:enabled="false" /></LinearLayout></LinearLayout>


记得加上相应权限~

附上图片结果:

 

http://www.lbrq.cn/news/2470087.html

相关文章:

  • c 做网站怎么插入id网络营销的公司有哪些
  • 做文件的网站网站优化建设
  • 织梦播放器网站苏州关键词排名提升
  • 拉萨做网站公司sem网络营销
  • 服务器里面如何做网站江门seo推广公司
  • 用c 做网站可以吗软文发布平台媒体
  • 网站头部固定网络营销过程步骤
  • 开服表网站开发创建一个网站
  • 网站建设比较好的网站发布与推广方式
  • 网站开发费用算无形资产关键词优化上海
  • 湖南土特产销售网网站建设制作武汉网站设计十年乐云seo
  • 代办公司执照重庆seo按天收费
  • 电商网站建设公司网站首页制作网站
  • 企业网站案例分析厦门seo关键词排名
  • 团员信息查询系统入口丽水网站seo
  • 营销网络是什么意思网站优化的主要内容
  • wordpress同步空间seo策略有哪些
  • 免费网站建设seo百度竞价品牌广告
  • 用什么网站推广广州网络优化最早的公司
  • 政府网站建设费用营销型网站定制
  • html5 单页 响应式 网站模板网络营销有什么
  • 明年做哪些网站致富新闻网站排行榜
  • 河北邢台有什么好玩的地方信息流优化师是干什么的
  • 商贸公司的网站建设百度网盘搜索引擎网站
  • 怎样制作网站站点湖南网站制作哪家好
  • 自己做的网站可以上架烟吗微信拓客的最新方法
  • php网站怎么做seo基础理论
  • 衡水网站建设套餐网站策划报告
  • 电子产品开发流程余姚网站seo运营
  • 做英语阅读的网站怎么制作网站教程步骤
  • 广东省省考备考(第五十七天7.26)——数量、言语(强化训练)
  • MongoDB数据库高并发商业实践优化·运行优化之不可使用root账户进行MongoDB运行-优雅草卓伊凡
  • Maven之依赖管理
  • 嵌入式硬件篇---zigbee无线串口通信问题解决方法
  • Linux的生态与软件安装
  • SpringBoot学习路径--SpringBoot的简单介绍和项目搭建