Android-判断数据业务是否开启

1,888 views

//Judge data connect
private void judgeDataState()
{
boolean netSataus = false;

ConnectivityManager mConnMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
if (mConnMgr.getActiveNetworkInfo() != null) {
netSataus = mConnMgr.getActiveNetworkInfo().isAvailable();
}

if(netSataus == false)
{
AlertDialog.Builder dialog = new AlertDialog.Builder(SiteMap.this);
dialog.setTitle(“数据业务功能未开启!”);
dialog.setMessage(“开启数据业务,获取卫星地图并享受更全面的功能!”);
dialog.setIcon(R.drawable.mobile_32);
dialog.setPositiveButton(“知道了”, null);
dialog.setNegativeButton(“设置”,DataState_listener_set);
dialog.show();
return;
}
}

//DataAndGPSState set
private DialogInterface.OnClickListener DataState_listener_set = new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
startActivityForResult(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS), 2);
}
};

转载本站文章请注明,转载自:阿达基站路测的天空[http://blog.signalsitemap.com]

本文链接:Android-判断数据业务是否开启 | 阿达基站路测的天空

This entry was posted in Android and tagged . Bookmark the permalink.

Comments are closed.