【发布时间】:2014-03-06 06:21:19
【问题描述】:
我在 android 中开发了一个应用程序。该应用程序由通过 Web 服务进行的服务器和客户端交互组成。我检查了 wifi 连接状态,如果连接状态为假,我已显示注意框,如果连接状态为真,我将执行一些操作。但我遇到的问题是注意框显示在 LG、Sony 和其他智能手机上,除了 SAMSUNG 所有型号,包括 Galaxy S4。
谁能知道这件事......
我将在下面发布检查 wifi、4g 和状态的代码。
boolean connected = false;
ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIMAX).getState() == NetworkInfo.State.CONNECTED)
{
// some action
//we are connected to a network
connected = true;
}
if(connected == false){
// System.out.println("The Network error");
attentionBox("There is no network connection right now. Please try again later.","Internet Connection Error");
}
注意框编码是:
public void attentionBox(final String msg, final String title)
{
AlertDialog.Builder builder = new AlertDialog.Builder(ViewYourPlanList.this);
builder.setMessage(msg)
.setTitle(title)
.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
((AlertDialog)dialog).getButton(which).setVisibility(View.INVISIBLE);
//finish();
System.exit(0);
}
});
AlertDialog alert = builder.create();
alert.show();
}
【问题讨论】:
-
可以分享一下attentionBox编码吗
-
我分享了彼得。它适用于除三星以外的所有其他手机????
标签: android performance web-services android-wifi galaxy