編輯:關於android開發
public class NetStateUtils {
/**
* 對網絡連接狀態進行判斷
*
* @return true, 可用; false, 不可用
*/
public static boolean isNetworkConnected(Context context) {
if (context != null) {
ConnectivityManager connManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
if (networkInfo != null) {
return networkInfo.isAvailable();
}
}
return false;
}
/**
* 提示設置網絡連接
*
*/
public static void alertSetNetwork(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getResources().getString(R.string.neterror)).setMessage(context.getString(R.string.question));
builder.setPositiveButton(context.getResources().getString(R.string.set), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = null;
try {
int sdkVersion = android.os.Build.VERSION.SDK_INT;
if (sdkVersion > 10) {
intent = new Intent(
android.provider.Settings.ACTION_WIRELESS_SETTINGS);
} else {
intent = new Intent();
ComponentName comp = new ComponentName(
"com.android.settings",
"com.android.settings.WirelessSettings");
intent.setComponent(comp);
intent.setAction("android.intent.action.VIEW");
}
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
});
builder.setNegativeButton(context.getString(R.string.cancle), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
System.exit(0);
System.gc();
}
});
builder.show();
}
}
【騰訊Bugly干貨分享】深入源碼探索 ReactNative 通信機制,buglyreactnativeBugly 技術干貨系列內容主要涉及移動開發方向,是由 Bugl
圖表框架HelloCharts(2)柱狀圖,hellocharts柱狀圖1.效果圖 2.xml代碼 activity_column_chart.xml <Fram
Linux內核調試技術——進程D狀態死鎖檢測Linux的進程存在多種狀態,如TASK_RUNNING的運行態、EXIT_DEAD的停止態和TASK_INTERRUPTIB
手把手教你畫一個 逼格滿滿圓形水波紋loadingview Android 才沒有完結呢o( ̄︶ ̄)n 。大家好,這裡是番外篇。 拜讀了愛哥的博客,又學到不少東西。愛哥曾
Android Studio系列教程一下載與安裝 背景Android S