Android获取设备信息
使用java:
List<TableMessage> dataList=new ArrayList<TableMessage>();//获取设备信息Hashtable<String,String> ht= MyDeviceInfo.getDeviceAllInfo2(LoginActivity.this);for (Map.Entry<String, String> entry : ht.entrySet()) {String key = entry.getKey();String value = entry.getValue();Log.d("Hashtable", "Key: " + key + ", Value: " + value);dataList.add(new TableMessage(key,value));}// String cpuABI = Build.CPU_ABI; // CPU架构(如arm64、x86)//int cpuCount = Runtime.getRuntime().availableProcessors(); // 逻辑核心数
// String info = "架构:" + cpuABI + "+
// 核心数:" + cpuCount;// dataList.add(new TableMessage("核心数:",cpuCount+""));DialogTableDeviceInfo dialogTableDeviceInfo=new DialogTableDeviceInfo();dialogTableDeviceInfo.show(LoginActivity.this,"设备信息",dataList);
显示xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:id="@+id/TextViewTitleSucces"android:layout_width="match_parent"android:layout_height="wrap_content"android:text=""android:textAlignment="center"android:textColor="@color/btnsetting"android:textSize="16sp" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginTop="5dp"android:orientation="horizontal"><ScrollViewandroid:layout_width="fill_parent"android:layout_height="match_parent"><HorizontalScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"><!-- 此处省略的组件的配置 --><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><LinearLayoutandroid:id="@+id/LinearLayout1"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:id="@+id/TextViewId"android:layout_width="30dp"android:layout_height="wrap_content"android:background="@drawable/border_background"android:text="@string/txt_dialog_id"android:textAlignment="center" /><TextViewandroid:id="@+id/TextViewName"android:layout_width="140dp"android:layout_height="wrap_content"android:background="@drawable/border_background"android:text="@string/txt_login_menu_about_name"android:textAlignment="center" /><TextViewandroid:id="@+id/TextViewQuantity"android:layout_width="300dp"android:layout_height="wrap_content"android:background="@drawable/border_background"android:text="@string/txt_login_menu_about_size"android:textAlignment="center" /></LinearLayout><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/recyclerView"android:layout_width="match_parent"android:layout_height="match_parent"android:clipToPadding="false"android:padding="0dp"android:scrollbars="horizontal|vertical" /></LinearLayout></RelativeLayout></HorizontalScrollView></ScrollView></LinearLayout>
<!-- <ListView-->
<!-- android:id="@+id/ListView_table"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"--><!-- android:scrollbars="horizontal|vertical">--><!-- </ListView>--><!-- <ListView-->
<!-- android:id="@+id/ListView_table_fail"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"--><!-- android:scrollbars="horizontal|vertical" />--></LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="wrap_content"android:textAlignment="center"tools:ignore="MissingDefaultResource"><TextViewandroid:id="@+id/TextViewId"android:layout_width="30dp"android:layout_height="wrap_content"android:background="@drawable/border_background"android:text="@string/txt_dialog_id"android:textAlignment="center" /><TextViewandroid:id="@+id/TextViewName"android:layout_width="140dp"android:layout_height="wrap_content"android:background="@drawable/border_background"android:paddingRight="5dp"android:text=""android:textAlignment="textEnd" /><TextViewandroid:id="@+id/TextViewQuantity"android:layout_width="400dp"android:layout_height="wrap_content"android:background="@drawable/border_background"android:text=""android:textAlignment="viewStart" /></LinearLayout>
设备信息java代码:
package com.demo.util;import static android.content.Context.ACTIVITY_SERVICE;
import static android.util.Log.ERROR;
import static com.demo.util.FileUtilsPi.externalMemoryAvailable;import android.app.ActivityManager;
import android.content.Context;
import android.icu.text.DecimalFormat;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.util.Log;import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.Locale;
public class MyDeviceInfo {//内存(RAM)信息获取public void getMemoryInfo() {String str1 = "/proc/meminfo";String str2="";try {FileReader fr = new FileReader(str1);BufferedReader localBufferedReader = new BufferedReader(fr, 8192);while ((str2 = localBufferedReader.readLine()) != null) {Log.d("TAG", "---" + str2);}} catch (IOException e) {}}/*** 获取可用手机内存(RAM)* @return*/public static long getAvailMemory(Context context) {ActivityManager am = (ActivityManager)context.getSystemService(ACTIVITY_SERVICE);ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();am.getMemoryInfo(mi);return mi.availMem;}/*** 获取手机内部空间大小* @return*/public static long getTotalInternalStorgeSize() {File path = Environment.getDataDirectory();StatFs mStatFs = new StatFs(path.getPath());long blockSize = mStatFs.getBlockSize();long totalBlocks = mStatFs.getBlockCount();return totalBlocks * blockSize;}/*** 获取手机内部可用空间大小* @return*/public static long getAvailableInternalStorgeSize() {File path = Environment.getDataDirectory();StatFs mStatFs = new StatFs(path.getPath());long blockSize = mStatFs.getBlockSize();long availableBlocks = mStatFs.getAvailableBlocks();return availableBlocks * blockSize;}/*** 获取手机外部空间大小* @return*/public static long getTotalExternalStorgeSize() {if (externalMemoryAvailable()) {File path = Environment.getExternalStorageDirectory();StatFs mStatFs = new StatFs(path.getPath());long blockSize = mStatFs.getBlockSize();long totalBlocks = mStatFs.getBlockCount();return totalBlocks * blockSize;} else {return ERROR;}}/*** 获取手机外部可用空间大小* @return*/public static long getAvailableExternalStorgeSize() {if (externalMemoryAvailable()) {File path = Environment.getExternalStorageDirectory();StatFs mStatFs = new StatFs(path.getPath());long blockSize = mStatFs.getBlockSize();long availableBlocks = mStatFs.getAvailableBlocks();return availableBlocks * blockSize;} else {return ERROR;}}/* 返回为字符串数组[0]为大小[1]为单位KB或MB */public static String formatSize(long size) {String suffix = "";float fSzie = 0;if (size >= 1024) {suffix = "KB";fSzie = size / 1024;if (fSzie >= 1024) {suffix = "MB";fSzie /= 1024;if (fSzie >= 1024) {suffix = "GB";fSzie /= 1024;}}}DecimalFormat formatter = new DecimalFormat("#0.00");// 字符显示格式/* 每3个数字用,分隔,如1,000 */formatter.setGroupingSize(3);StringBuilder resultBuffer = new StringBuilder(formatter.format(fSzie));if (suffix != null) {resultBuffer.append(suffix);}return resultBuffer.toString();}/* 返回为字符串数组[0]为大小[1]为单位KB或MB */public static String[] formatSizeArr(long size) {String[] arr = new String[2];String suffix = "";float fSzie = 0;arr[0]="";if (size >= 1024) {suffix = "KB";fSzie = size / 1024;if (fSzie >= 1024) {suffix = "MB";fSzie /= 1024;if (fSzie >= 1024) {suffix = "GB";fSzie /= 1024;}}}DecimalFormat formatter = new DecimalFormat("#0.00");// 字符显示格式/* 每3个数字用,分隔,如1,000 */formatter.setGroupingSize(3);StringBuilder resultBuffer = new StringBuilder(formatter.format(fSzie));if (suffix != null) {resultBuffer.append(suffix);}return arr;}/*** 获取设备宽度(px)**/public static int getDeviceWidth(Context context) {return context.getResources().getDisplayMetrics().widthPixels;}/*** 获取设备高度(px)*/public static int getDeviceHeight(Context context) {return context.getResources().getDisplayMetrics().heightPixels;}/*** 获取设备的唯一标识, 需要 “android.permission.READ_Phone_STATE”权限*/public static String getIMEI(Context context) {TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);String deviceId = tm.getDeviceId();if (deviceId == null) {return "UnKnown";} else {return deviceId;}}/*** 获取厂商名* **/public static String getDeviceManufacturer() {return android.os.Build.MANUFACTURER;}/*** 获取产品名* **/public static String getDeviceProduct() {return android.os.Build.PRODUCT;}/*** 获取手机品牌*/public static String getDeviceBrand() {return android.os.Build.BRAND;}/*** 获取手机型号*/public static String getDeviceModel() {return android.os.Build.MODEL;}/*** 获取手机主板名*/public static String getDeviceBoard() {return android.os.Build.BOARD;}/*** 设备名* **/public static String getDeviceDevice() {return android.os.Build.DEVICE;}/***** fingerprit 信息* **/public static String getDeviceFubgerprint() {return android.os.Build.FINGERPRINT;}/*** 硬件名** **/public static String getDeviceHardware() {return android.os.Build.HARDWARE;}/*** 主机** **/public static String getDeviceHost() {return android.os.Build.HOST;}/**** 显示ID* **/public static String getDeviceDisplay() {return android.os.Build.DISPLAY;}/*** ID** **/public static String getDeviceId() {return android.os.Build.ID;}/*** 获取手机用户名** **/public static String getDeviceUser() {return android.os.Build.USER;}/*** 获取手机 硬件序列号* **/public static String getDeviceSerial() {return android.os.Build.SERIAL;}/*** 获取手机Android 系统SDK** @return*/public static int getDeviceSDK() {return android.os.Build.VERSION.SDK_INT;}/*** 获取手机Android 版本** @return*/public static String getDeviceAndroidVersion() {return android.os.Build.VERSION.RELEASE;}/*** 获取当前手机系统语言。*/public static String getDeviceDefaultLanguage() {return Locale.getDefault().getLanguage();}/*** 获取当前系统上的语言列表(Locale列表)*/public static String getDeviceSupportLanguage() {Log.e("wangjie", "Local:" + Locale.GERMAN);Log.e("wangjie", "Local:" + Locale.ENGLISH);Log.e("wangjie", "Local:" + Locale.US);Log.e("wangjie", "Local:" + Locale.CHINESE);Log.e("wangjie", "Local:" + Locale.TAIWAN);Log.e("wangjie", "Local:" + Locale.FRANCE);Log.e("wangjie", "Local:" + Locale.FRENCH);Log.e("wangjie", "Local:" + Locale.GERMANY);Log.e("wangjie", "Local:" + Locale.ITALIAN);Log.e("wangjie", "Local:" + Locale.JAPAN);Log.e("wangjie", "Local:" + Locale.JAPANESE);StringBuilder sb=new StringBuilder();sb.append(Locale.CHINESE+"、"+Locale.US);return sb.toString();}public static String getDeviceAllInfo(Context context) {return "\n\n1. IMEI:\n\t\t" + getIMEI(context)+ "\n\n2. 设备宽度:\n\t\t" + getDeviceWidth(context)+ "\n\n3. 设备高度:\n\t\t" + getDeviceHeight(context)+ "\n\n4. 是否有内置SD卡:\n\t\t" + SDCardUtils.isSDCardMount()+ "\n\n5. RAM 信息:\n\t\t" + SDCardUtils.getRAMInfo(context)+ "\n\n6. 内部存储信息\n\t\t" + SDCardUtils.getStorageInfo(context, 0)+ "\n\n7. SD卡 信息:\n\t\t" + SDCardUtils.getStorageInfo(context, 1)// + "\n\n8. 是否联网:\n\t\t" + Utils.isNetworkConnected(context)
//
// + "\n\n9. 网络类型:\n\t\t" + Utils.GetNetworkType(context)+ "\n\n10. 系统默认语言:\n\t\t" + getDeviceDefaultLanguage()+ "\n\n11. 硬件序列号(设备名):\n\t\t" + android.os.Build.SERIAL+ "\n\n12. 手机型号:\n\t\t" + android.os.Build.MODEL+ "\n\n13. 生产厂商:\n\t\t" + android.os.Build.MANUFACTURER+ "\n\n14. 手机Fingerprint标识:\n\t\t" + android.os.Build.FINGERPRINT+ "\n\n15. Android 版本:\n\t\t" + android.os.Build.VERSION.RELEASE+ "\n\n16. Android SDK版本:\n\t\t" + android.os.Build.VERSION.SDK_INT+ "\n\n17. 安全patch 时间:\n\t\t" + android.os.Build.VERSION.SECURITY_PATCH// + "\n\n18. 发布时间:\n\t\t" + Utils.Utc2Local(android.os.Build.TIME)+ "\n\n19. 版本类型:\n\t\t" + android.os.Build.TYPE+ "\n\n20. 用户名:\n\t\t" + android.os.Build.USER+ "\n\n21. 产品名:\n\t\t" + android.os.Build.PRODUCT+ "\n\n22. ID:\n\t\t" + android.os.Build.ID+ "\n\n23. 显示ID:\n\t\t" + android.os.Build.DISPLAY+ "\n\n24. 硬件名:\n\t\t" + android.os.Build.HARDWARE+ "\n\n25. 产品名:\n\t\t" + android.os.Build.DEVICE+ "\n\n26. Bootloader:\n\t\t" + android.os.Build.BOOTLOADER+ "\n\n27. 主板名:\n\t\t" + android.os.Build.BOARD+ "\n\n28. CodeName:\n\t\t" + android.os.Build.VERSION.CODENAME+ "\n\n29. 语言支持:\n\t\t" + getDeviceSupportLanguage();}public static String GetDeivceAllInfo2(){String DeviceMessage="产品 :" + android.os.Build.PRODUCT+"\nCPU_ABI :" + android.os.Build.CPU_ABI+ "\n 标签 :" + android.os.Build.TAGS+ "\n VERSION_CODES.BASE:" + android.os.Build.VERSION_CODES.BASE+ "\n 型号:" + android.os.Build.MODEL+"\n SDK : " + android.os.Build.VERSION.SDK+"\n Android 版本 : " + android.os.Build.VERSION.RELEASE+ "\n 驱动 : " + android.os.Build.DEVICE+"\n DISPLAY: " + android.os.Build.DISPLAY+"\n 品牌 : " + android.os.Build.BRAND+"\n 基板 : " + android.os.Build.BOARD+"\n 设备标识 : " + android.os.Build.FINGERPRINT+"\n 版本号 : " + android.os.Build.ID+ "\n 制造商 : " + android.os.Build.MANUFACTURER+"\n 用户 : " + android.os.Build.USER+"\n CPU_ABI2 : "+android.os.Build.CPU_ABI2+"\n 硬件 : "+ android.os.Build.HARDWARE+"\n 主机地址 :"+android.os.Build.HOST+"\n 未知信息 : "+android.os.Build.UNKNOWN+"\n 版本类型 : "+android.os.Build.TYPE+"\n 时间 : "+String.valueOf(android.os.Build.TIME)+"\n Radio : "+android.os.Build.RADIO+"\n 序列号 : "+android.os.Build.SERIAL;return DeviceMessage;}public static Hashtable<String,String> getDeviceAllInfo2(Context context) {Hashtable<String,String> ht=new Hashtable<String,String>();// ht.put("IMEI:",getIMEI(context));ht.put("设备宽度:",getDeviceWidth(context)+"");ht.put("设备高度:",getDeviceHeight(context)+"");ht.put("RAM 信息:",SDCardUtils.getRAMInfo(context)+"");ht.put("内部存储信息:",SDCardUtils.getStorageInfo(context, 0)+"");ht.put("是否有内置SD卡:",SDCardUtils.isSDCardMount()+"");ht.put("SD卡信息:",SDCardUtils.getStorageInfo(context, 1)+"");ht.put("系统默认语言:",getDeviceDefaultLanguage()+"");ht.put("硬件序列号(设备名):", android.os.Build.SERIAL+"");ht.put("设备型号:",android.os.Build.MODEL+"");ht.put("生产厂商:",android.os.Build.MANUFACTURER+"");// ht.put("手机Fingerprint标识:",android.os.Build.FINGERPRINT+"");ht.put("Android 版本:",android.os.Build.VERSION.RELEASE+"");ht.put("Android SDK版本:",android.os.Build.VERSION.SDK_INT+"");ht.put("安全patch 时间:",android.os.Build.VERSION.SECURITY_PATCH+"");ht.put("版本类型:",android.os.Build.TYPE+"");ht.put("用户名:",android.os.Build.USER+"");ht.put("ID:",android.os.Build.ID+"");ht.put("显示ID:",android.os.Build.DISPLAY+"");ht.put("硬件名:",android.os.Build.HARDWARE+"");ht.put("产品名:",android.os.Build.DEVICE+"");ht.put("Bootloader:",android.os.Build.BOOTLOADER+"");ht.put("主板名:",android.os.Build.BOARD+"");ht.put("主机:", Build.HOST+"");ht.put("CodeName:",android.os.Build.VERSION.CODENAME+"");ht.put("语言支持:",getDeviceSupportLanguage()+"");//支持卡槽数量(sdk_version>=23才可取值,否则为0slot_count// ht.put(" 支持卡槽数量:",android.os.Build.+"");ht.put("CPU名字:", Build.CPU_ABI+"");ht.put("CPU_ABI2:", android.os.Build.CPU_ABI2+"");ht.put("CPU核心数:", Runtime.getRuntime().availableProcessors()+"");// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
// if (activityManager == null) {
// throw new IllegalStateException("ActivityManager is not available");
// }
//
// // 创建MemoryInfo对象并填充数据
// ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
// activityManager.getMemoryInfo(memoryInfo);
//
// // 提取总运行内存和可用运行内存
// long totalMemory = memoryInfo.totalMem; // 总运行内存(含已用)
// long availableMemory = memoryInfo.availMem; // 可用运行内存(不含已用)
// 转换为 MB(保留两位小数)
// String totalMemoryMB = String.format("%.2f GB", totalMemory / (1024.0 * 1024*1024));
// String availableMemoryMB = String.format("%.2f GB", availableMemory / (1024.0 * 1024*1024));
// ht.put("运行内存:", "总运行内存/可用运行内存"+totalMemoryMB+"/"+availableMemoryMB+"");// ht.put(" 蓝牙mac地址:", android.os.Build+"");// String message= "\n\n1. IMEI:\n\t\t" + getIMEI(context)
//
// + "\n\n2. 设备宽度:\n\t\t" + getDeviceWidth(context)
//
// + "\n\n3. 设备高度:\n\t\t" + getDeviceHeight(context)
//
// + "\n\n4. 是否有内置SD卡:\n\t\t" + SDCardUtils.isSDCardMount()
//
// + "\n\n5. RAM 信息:\n\t\t" + SDCardUtils.getRAMInfo(context)
//
// + "\n\n6. 内部存储信息\n\t\t" + SDCardUtils.getStorageInfo(context, 0)
//
// + "\n\n7. SD卡 信息:\n\t\t" + SDCardUtils.getStorageInfo(context, 1)
//+ "\n\n8. 是否联网:\n\t\t" + Utils.isNetworkConnected(context)+ "\n\n9. 网络类型:\n\t\t" + Utils.GetNetworkType(context)
//
// + "\n\n10. 系统默认语言:\n\t\t" + getDeviceDefaultLanguage()
//
// + "\n\n11. 硬件序列号(设备名):\n\t\t" + android.os.Build.SERIAL
//
// + "\n\n12. 手机型号:\n\t\t" + android.os.Build.MODEL
//
// + "\n\n13. 生产厂商:\n\t\t" + android.os.Build.MANUFACTURER
//
// + "\n\n14. 手机Fingerprint标识:\n\t\t" + android.os.Build.FINGERPRINT
//
// + "\n\n15. Android 版本:\n\t\t" + android.os.Build.VERSION.RELEASE
//
// + "\n\n16. Android SDK版本:\n\t\t" + android.os.Build.VERSION.SDK_INT
//
// + "\n\n17. 安全patch 时间:\n\t\t" + android.os.Build.VERSION.SECURITY_PATCH
//+ "\n\n18. 发布时间:\n\t\t" + Utils.Utc2Local(android.os.Build.TIME)
//
// + "\n\n19. 版本类型:\n\t\t" + android.os.Build.TYPE
//
// + "\n\n20. 用户名:\n\t\t" + android.os.Build.USER
//
// + "\n\n21. 产品名:\n\t\t" + android.os.Build.PRODUCT
//
// + "\n\n22. ID:\n\t\t" + android.os.Build.ID
//
// + "\n\n23. 显示ID:\n\t\t" + android.os.Build.DISPLAY
//
// + "\n\n24. 硬件名:\n\t\t" + android.os.Build.HARDWARE
//
// + "\n\n25. 产品名:\n\t\t" + android.os.Build.DEVICE
//
// + "\n\n26. Bootloader:\n\t\t" + android.os.Build.BOOTLOADER
//
// + "\n\n27. 主板名:\n\t\t" + android.os.Build.BOARD
//
// + "\n\n28. CodeName:\n\t\t" + android.os.Build.VERSION.CODENAME
// + "\n\n29. 语言支持:\n\t\t" + getDeviceSupportLanguage();getCPUInfo();return ht;}public static String getCPUInfo() {StringBuilder cpuInfo = new StringBuilder();try {// 执行cat命令读取文件Process process = Runtime.getRuntime().exec("cat /proc/cpuinfo");BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));String line;while ((line = reader.readLine()) != null) {cpuInfo.append(line).append("");Log.d("MemoryInfo", "Available RAM: " + line);}reader.close();} catch (IOException e) {e.printStackTrace();return "获取失败";}return cpuInfo.toString();}public static String getRAM(Context context){// // 获取内存信息
// ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
// ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
// activityManager.getMemoryInfo(memoryInfo);
//提取数据并转换单位
// long totalMemory = memoryInfo.totalMem;
// long availableMemory = memoryInfo.availMem;
//转换为 MB(保留两位小数)
// String totalMemoryMB = String.format("%.2f MB", totalMemory / (1024.0 * 1024));
// String availableMemoryMB = String.format("%.2f MB", availableMemory / (1024.0 * 1024));
//
// Log.d("MemoryInfo", "Total RAM: " + totalMemoryMB);
// Log.d("MemoryInfo", "Available RAM: " + availableMemoryMB);return "";}/*** 获取CPU总运行内存和可用运行内存(单位:字节)** @param context 应用上下文* @return 包含总运行内存和可用运行内存的数组,索引0为总内存,索引1为可用内存*/public static String[] getCpuAndAvailableMemory(Context context) {// 获取ActivityManager实例ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);if (activityManager == null) {throw new IllegalStateException("ActivityManager is not available");}// 创建MemoryInfo对象并填充数据ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();activityManager.getMemoryInfo(memoryInfo);// 提取总运行内存和可用运行内存long totalMemory = memoryInfo.totalMem; // 总运行内存(含已用)long availableMemory = memoryInfo.availMem; // 可用运行内存(不含已用)转换为 MB(保留两位小数)String totalMemoryMB = String.format("%.2f MB", totalMemory / (1024.0 * 1024));String availableMemoryMB = String.format("%.2f MB", availableMemory / (1024.0 * 1024));return new String[]{totalMemoryMB, availableMemoryMB};}
}
package com.uhf200.demo.util;import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;import com.uhf200.demo.R;
import com.uhf200.demo.ui.model.TableMessage;import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;public class DialogTableDeviceInfo {public static AlertDialog alertDialog3; //输入弹出框public static ListView dialog_ListView;public static DialogAdapter dialogAdapter;private static List<TableMessage> mArrCard;//返回失败的信息public static ListView dialog_ListView_fail;public static DialogFailAdapter dialogFailAdapter;private static List<TableMessage> mArrCard_fail;public void show(Context context, String title_succes,List<TableMessage> dataList) {AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);alertBuilder.setTitle("设备信息");mArrCard=new ArrayList<TableMessage>();mArrCard_fail=new ArrayList<TableMessage>();mArrCard=dataList;// 引入自己设计的xml//成功的提示信息View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_table_device_info,null);TextView TextViewSucces= dialogView.findViewById(R.id.TextViewTitleSucces);LinearLayout LinearLayout1= dialogView.findViewById(R.id.LinearLayout1);LinearLayout LinearLayout2= dialogView.findViewById(R.id.LinearLayout2);// dialog_ListView = (ListView) dialogView.findViewById(R.id.ListView_table);
//
// dialogAdapter = new DialogAdapter(context, mArrCard);
//
// dialog_ListView.setAdapter(dialogAdapter);
//
// dialog_ListView.setVerticalScrollBarEnabled(true);//失败的信息// dialog_ListView_fail = (ListView) dialogView.findViewById(R.id.ListView_table_fail);
//
// dialogFailAdapter = new DialogFailAdapter(context, mArrCard_fail);
//
// dialog_ListView_fail.setAdapter(dialogFailAdapter);
//
// dialog_ListView_fail.setVerticalScrollBarEnabled(true);// TableLayout tableLayout = dialogView.findViewById(R.id.table_layout);TextViewSucces.setText(title_succes);// dialogAdapter.notifyDataSetChanged();
// dialogFailAdapter.notifyDataSetChanged();alertBuilder.setView(dialogView);alertBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialogInterface, int i) {alertDialog3.dismiss();}});//成功的信息RecyclerView recyclerView = dialogView.findViewById(R.id.recyclerView);// 设置垂直列表布局recyclerView.setLayoutManager(new LinearLayoutManager(context));// 准备测试数据List<TableMessage> userList = new ArrayList<>();
// for (int i=0;i<100;i++){
// userList.add(new TableMessage("张三"+i, "2"+i));
// }
//
// userList.add(new TableMessage("李四", "30"));
// userList.add(new TableMessage("王五", "28"));// 添加更多数据...if(dataList.size()>0){userList=dataList;}else {TextViewSucces.setVisibility(View.GONE);recyclerView.setVisibility(View.GONE);LinearLayout1.setVisibility(View.GONE);LinearLayout2.setVisibility(View.GONE);}// 创建并设置 AdapterUserAdapter adapter = new UserAdapter(userList);recyclerView.setAdapter(adapter);//添加数据
// for (int i = 0; i < dataList.size(); i++) {
//
// TableMessage tableMessage=dataList.get(i);
// addDataRow(context,tableLayout, i + 1,
// tableMessage.getName(),
// tableMessage.getQuantity());
// }// alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
//
// alertDialog3.dismiss();
//
// }
// });alertDialog3 = alertBuilder.create();alertDialog3.show();}public void show(Context context, String title_succes,String title_fail,List<TableMessage> dataList, List<TableMessage> dataList_fail,String errorMessage) {AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);alertBuilder.setTitle("设备信息");mArrCard=new ArrayList<TableMessage>();mArrCard_fail=new ArrayList<TableMessage>();mArrCard=dataList;mArrCard_fail=dataList_fail;// 引入自己设计的xml//成功的提示信息View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_table_device_info,null);TextView TextViewSucces= dialogView.findViewById(R.id.TextViewTitleSucces);LinearLayout LinearLayout1= dialogView.findViewById(R.id.LinearLayout1);LinearLayout LinearLayout2= dialogView.findViewById(R.id.LinearLayout2);// dialog_ListView = (ListView) dialogView.findViewById(R.id.ListView_table);
//
// dialogAdapter = new DialogAdapter(context, mArrCard);
//
// dialog_ListView.setAdapter(dialogAdapter);
//
// dialog_ListView.setVerticalScrollBarEnabled(true);//失败的信息// dialog_ListView_fail = (ListView) dialogView.findViewById(R.id.ListView_table_fail);
//
// dialogFailAdapter = new DialogFailAdapter(context, mArrCard_fail);
//
// dialog_ListView_fail.setAdapter(dialogFailAdapter);
//
// dialog_ListView_fail.setVerticalScrollBarEnabled(true);// TableLayout tableLayout = dialogView.findViewById(R.id.table_layout);TextViewSucces.setText(title_succes);// dialogAdapter.notifyDataSetChanged();
// dialogFailAdapter.notifyDataSetChanged();alertBuilder.setView(dialogView);alertBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialogInterface, int i) {alertDialog3.dismiss();}});//成功的信息RecyclerView recyclerView = dialogView.findViewById(R.id.recyclerView);// 设置垂直列表布局recyclerView.setLayoutManager(new LinearLayoutManager(context));// 准备测试数据List<TableMessage> userList = new ArrayList<>();
// for (int i=0;i<100;i++){
// userList.add(new TableMessage("张三"+i, "2"+i));
// }
//
// userList.add(new TableMessage("李四", "30"));
// userList.add(new TableMessage("王五", "28"));// 添加更多数据...if(dataList.size()>0){userList=dataList;}else {TextViewSucces.setVisibility(View.GONE);recyclerView.setVisibility(View.GONE);LinearLayout1.setVisibility(View.GONE);LinearLayout2.setVisibility(View.GONE);}// 创建并设置 AdapterUserAdapter adapter = new UserAdapter(userList);recyclerView.setAdapter(adapter);//添加数据
// for (int i = 0; i < dataList.size(); i++) {
//
// TableMessage tableMessage=dataList.get(i);
// addDataRow(context,tableLayout, i + 1,
// tableMessage.getName(),
// tableMessage.getQuantity());
// }// alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
//
// alertDialog3.dismiss();
//
// }
// });alertDialog3 = alertBuilder.create();alertDialog3.show();}private static void addDataRow(Context context,TableLayout tableLayout,int index,String name,String quantity) {TableRow dataRow = new TableRow(tableLayout.getContext());dataRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.WRAP_CONTENT));// 序号列TextView tvIndex = createTextView(context,String.valueOf(index),Color.BLACK,Gravity.LEFT);dataRow.addView(tvIndex);// 名称列TextView tvName = createTextView(context,name,Color.BLACK,Gravity.START);dataRow.addView(tvName);// 数量列TextView tvQuantity = createTextView(context,quantity,Color.BLACK,Gravity.CENTER);dataRow.addView(tvQuantity);// 添加底部边框
// View divider = new View(tableLayout.getContext());
// divider.setLayoutParams(new TableRow.LayoutParams(
// TableRow.LayoutParams.MATCH_PARENT,
// 2));
// divider.setBackgroundColor(Color.LTGRAY);
// dataRow.addView(divider);tableLayout.addView(dataRow);}private static TextView createTextView(Context context,String text,int textColor,int gravity) {TextView tv = new TextView(context);tv.setLayoutParams(new TableRow.LayoutParams(0,TableRow.LayoutParams.WRAP_CONTENT,1f));tv.setText(text);tv.setTextColor(textColor);tv.setGravity(gravity);tv.setPadding(16, 12, 16, 12);return tv;}public class DialogAdapter extends BaseAdapter {private Context context;private LayoutInflater inflater;public List<TableMessage> arraylist;public int i=1;//刷新数据public int optionindex;public DialogAdapter(Context context) {super();this.context = context;inflater = LayoutInflater.from(context);arraylist = new ArrayList<TableMessage>();}public DialogAdapter( Context context, List<TableMessage> arraylist) {super();inflater = LayoutInflater.from(context);this.context = context;this.arraylist = arraylist;}@Overridepublic int getCount() {// TODO Auto-generated method stubreturn arraylist.size();}@Overridepublic Object getItem(int arg0) {// TODO Auto-generated method stubreturn arg0;}@Overridepublic long getItemId(int arg0) {// TODO Auto-generated method stubreturn arg0;}@Overridepublic View getView(final int position, View convertView, ViewGroup parent) {// TODO Auto-generated method stubViewDialog viewDialog=null;try {if (convertView == null) {viewDialog=new ViewDialog();convertView=inflater.inflate(R.layout.device_item_info, null);viewDialog.tvId = (TextView)convertView.findViewById(R.id.TextViewId);viewDialog.tv_Name= (TextView) convertView.findViewById(R.id.TextViewName);viewDialog.tv_Quantity= (TextView) convertView.findViewById(R.id.TextViewQuantity);}else {viewDialog = (ViewDialog)convertView.getTag();// resetViewHolder(viewDialog);}TableMessage tableMessage = arraylist.get(position);viewDialog.tvId.setText((position+1)+"");viewDialog.tv_Name.setText(tableMessage.getName());viewDialog.tv_Quantity.setText(tableMessage.getQuantity());return convertView;} catch (Exception e) {Log.d("debugAdd", "3测试添加数据有误" + e.toString());return convertView;// throw new RuntimeException(e);}/// return view;}protected void resetViewHolder(ViewDialog p_ViewHolder){p_ViewHolder.tvId.setText(null);p_ViewHolder.tv_Name.setText(null);p_ViewHolder.tv_Quantity.setText(null);}private class ViewDialog{private TextView tvId;private TextView tv_Name;private TextView tv_Quantity;}}public class DialogFailAdapter extends BaseAdapter {private Context context;private LayoutInflater inflater;public List<TableMessage> arraylist;public Hashtable<String,String> ht_AssetNames;public int i=1;//刷新数据public int optionindex;public DialogFailAdapter(Context context) {super();this.context = context;inflater = LayoutInflater.from(context);arraylist = new ArrayList<TableMessage>();ht_AssetNames=new Hashtable<String,String>();}public DialogFailAdapter( Context context, List<TableMessage> arraylist) {super();inflater = LayoutInflater.from(context);this.context = context;this.arraylist = arraylist;ht_AssetNames=new Hashtable<String,String>();}@Overridepublic int getCount() {// TODO Auto-generated method stubreturn arraylist.size();}@Overridepublic Object getItem(int arg0) {// TODO Auto-generated method stubreturn arg0;}@Overridepublic long getItemId(int arg0) {// TODO Auto-generated method stubreturn arg0;}@Overridepublic View getView(final int position, View view, ViewGroup parent) {// TODO Auto-generated method stubViewDialog3 viewDialog3=null;try {if (view == null) {viewDialog3=new ViewDialog3();view=inflater.inflate(R.layout.device_item_info, null);viewDialog3.tvId = (TextView)view.findViewById(R.id.TextViewId3);viewDialog3.tv_Name= (TextView) view.findViewById(R.id.TextViewName3);viewDialog3.tv_Quantity= (TextView) view.findViewById(R.id.TextViewQuantity3);}else {viewDialog3 = (ViewDialog3)view.getTag();// resetViewHolder3(viewDialog3);}TableMessage tableMessage = arraylist.get(position);viewDialog3.tvId.setText((position+1)+"");viewDialog3.tv_Name.setText(tableMessage.getName());viewDialog3.tv_Quantity.setText(tableMessage.getQuantity());return view;} catch (Exception e) {Log.d("debugAdd", "3测试添加数据有误" + e.toString());return view;// throw new RuntimeException(e);}/// return view;}protected void resetViewHolder3(ViewDialog3 p_ViewHolder){p_ViewHolder.tvId.setText(null);p_ViewHolder.tv_Name.setText(null);p_ViewHolder.tv_Quantity.setText(null);}private class ViewDialog3{private TextView tvId;private TextView tv_Name;private TextView tv_Quantity;}}public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {private List<TableMessage> userList;public UserAdapter(List<TableMessage> userList) {this.userList = userList;}@NonNull@Overridepublic ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.device_item_info, parent, false);return new ViewHolder(view);}@Overridepublic void onBindViewHolder(@NonNull ViewHolder holder, int position) {// 获取当前数据TableMessage tableMessage = userList.get(position);// 设置序号(position 从 0 开始,需 +1)holder.tvId.setText(String.valueOf(position + 1));// 设置姓名和年龄holder.tv_Name.setText(tableMessage.getName());holder.tv_Quantity.setText(tableMessage.getQuantity());}@Overridepublic int getItemCount() {return userList.size();}// ViewHolder 内部类public class ViewHolder extends RecyclerView.ViewHolder {TextView tvId, tv_Name, tv_Quantity;public ViewHolder(@NonNull View itemView) {super(itemView);tvId = itemView.findViewById(R.id.TextViewId);tv_Name = itemView.findViewById(R.id.TextViewName);tv_Quantity = itemView.findViewById(R.id.TextViewQuantity);}}}public class UserFailAdapter extends RecyclerView.Adapter<UserFailAdapter.ViewHolder> {private List<TableMessage> userList;public UserFailAdapter(List<TableMessage> userList) {this.userList = userList;}@NonNull@Overridepublic ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.device_item_info, parent, false);return new ViewHolder(view);}@Overridepublic void onBindViewHolder(@NonNull ViewHolder holder, int position) {// 获取当前数据TableMessage tableMessage = userList.get(position);// 设置序号(position 从 0 开始,需 +1)holder.tvId.setText(String.valueOf(position + 1));// 设置姓名和年龄holder.tv_Name.setText(tableMessage.getName());holder.tv_Quantity.setText(tableMessage.getQuantity());}@Overridepublic int getItemCount() {return userList.size();}// ViewHolder 内部类public class ViewHolder extends RecyclerView.ViewHolder {TextView tvId, tv_Name, tv_Quantity;public ViewHolder(@NonNull View itemView) {super(itemView);tvId = itemView.findViewById(R.id.TextViewId3);tv_Name = itemView.findViewById(R.id.TextViewName3);tv_Quantity = itemView.findViewById(R.id.TextViewQuantity3);}}}}
相关文章:
Android获取设备信息
使用java: List<TableMessage> dataListnew ArrayList<TableMessage>();//获取设备信息Hashtable<String,String> ht MyDeviceInfo.getDeviceAllInfo2(LoginActivity.this);for (Map.Entry<String, String> entry : ht.entrySet()) {String key entry…...

WPF的基础控件:布局控件(StackPanel DockPanel)
布局控件(StackPanel & DockPanel) 1 StackPanel的Orientation属性2 DockPanel的LastChildFill3 嵌套布局示例4 性能优化建议5 常见问题排查 在WPF开发中,布局控件是构建用户界面的基石。StackPanel和DockPanel作为两种最基础的布局容器&…...

apache的commons-pool2原理与使用详解
Apache Commons Pool2 是一个高效的对象池化框架,通过复用昂贵资源(如数据库连接、线程、网络连接)优化系统性能。 前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击…...

打印Yolo预训练模型的所有类别及对应的id
有时候我们可能只需要用yolo模型检测个别类别,并显示,这就需要知道id,以下代码可打印出 from ultralytics import YOLO# 加载模型 model YOLO(yolo11x.pt)# 打印所有类别名称及其对应的ID print(model.names) {0: person, 1: bicycle, 2: c…...
语法糖介绍(C++ Python)
语法糖(Syntactic Sugar)是编程语言中为了提升代码可读性和简洁性而设计的语法结构。它不改变语言的功能,但能让代码更易写和理解。以下是 C 和 Python 中常见的语法糖示例: C 中的常见语法糖 范围 for 循环(Range-bas…...
事务详解及面试常考知识点整理
事务详解及面试常考知识点整理 1. 什么是事务? **事务(Transaction)**是将多条 SQL 语句打包执行的操作单元,具有“一气呵成”的特性。就好比你要完成“把大象放进冰箱”这件事,一共分三步: 打开冰箱门把…...

设计模式26——解释器模式
写文章的初心主要是用来帮助自己快速的回忆这个模式该怎么用,主要是下面的UML图可以起到大作用,在你学习过一遍以后可能会遗忘,忘记了不要紧,只要看一眼UML图就能想起来了。同时也请大家多多指教。 解释器模式(Interp…...

在MDK中自动部署LVGL,在stm32f407ZGT6移植LVGL-8.3,运行demo,显示label
在MDK中自动部署LVGL,在stm32f407ZGT6移植LVGL-8.3 一、硬件平台二、实现功能三、移植步骤1、下载LVGL-8.42、MDK中安装LVGL-8.43、配置RTE4、配置头文件 lv_conf_cmsis.h5、配置lv_port_disp_template 四、添加心跳相关文件1、在STM32CubeMX中配置TIM7的参数2、使能…...

ArcGIS 与 HEC-RAS 协同:流域水文分析与洪水模拟全流程
技术点目录 洪水淹没危险性评价方法及技术介绍基于ArcGIS的水文分析基于HecRAS淹没模拟的洪水危险性评价洪水风险评价综合案例分析应用了解更多 —————————————————————————————————————————————————— 前言综述 洪水危险性及…...
树莓派设置静态ip 永久有效 我的需要设置三个 一个摄像头的 两个设备的
通过 systemd-networkd 配置 此方法适用于较新的Raspberry Pi OS版本,支持同时绑定多个IP地址到同一网卡,且配置清晰稳定。 1.禁用DHCP客户端对eth0的管理:编辑/etc/dhcpcd.conf文件,添加以下内容以忽略eth0接口的自动分配 sudo nano /etc…...

多模态大语言模型arxiv论文略读(九十九)
PartGLEE: A Foundation Model for Recognizing and Parsing Any Objects ➡️ 论文标题:PartGLEE: A Foundation Model for Recognizing and Parsing Any Objects ➡️ 论文作者:Junyi Li, Junfeng Wu, Weizhi Zhao, Song Bai, Xiang Bai ➡️ 研究机构…...

Fine-tuning:微调技术,训练方式,LLaMA-Factory,ms-swift
1,微调技术 特征Full-tuningFreeze-tuningLoRAQLoRA训练参数量全部少量极少极少显存需求高低很低最低模型性能最佳中等较好接近 LoRA模型修改方式无变化局部冻结插入模块量化插入模块多任务共享不便较便非常适合非常适合适合超大模型微调❌✅✅✅(最优&…...
vscode连接的linux服务器,上传项目至github
问题 已将项目整个文件夹拷贝到克隆下来的文件夹中,并添加了所有文件,并修改了commit -m,使用git push -u origin main提交的时候会出现vscode请求登录github,确定之后需要等待很久,也无果 原因 由于 远程服务器无法…...

XCTF-web-mfw
发现了git 使用GitHack下载一下源文件,找到了php源代码 <?phpif (isset($_GET[page])) {$page $_GET[page]; } else {$page "home"; }$file "templates/" . $page . ".php";// I heard .. is dangerous! assert("strpos…...
indel_snp_ssr_primer
indel标记使用 1.得到vcf文件 2.提取指定区域vcf文件并压缩构建索引 bcftools view -r <CHROM>:<START>-<END> input.vcf -o output.vcf bgzip -c all.filtered.indel.vcf > all.filtered.indel.vcf.gz tabix -p vcf all.filtered.indel.vcf.gz3.准备参…...
图论核心:深度搜索DFS 与广度搜索BFS
一、深度优先搜索(DFS):一条路走到黑的探索哲学 1. 算法核心思想 DFS(Depth-First Search)遵循 “深度优先” 原则,从起始节点出发,尽可能深入地访问每个分支,直到无法继续时回溯&a…...
Java 调用 HTTP 和 HTTPS 的方式详解
文章目录 1. HTTP 和 HTTPS 基础知识1.1 什么是 HTTP/HTTPS?1.2 HTTP 请求与响应结构1.3 常见的 HTTP 方法1.4 常见的 HTTP 状态码 2. Java 原生 HTTP 客户端2.1 使用 URLConnection 和 HttpURLConnection2.1.1 基本 GET 请求2.1.2 基本 POST 请求2.1.3 处理 HTTPS …...
Redis--基础知识点--28--慢查询相关
1 慢查询的原因 1.1 非命令数据相关原因 1.1.1 网络延迟 原因:客户端与 Redis 服务器之间的网络延迟可能导致客户端感知到的响应时间变长。 解决方案:优化网络环境 排查: 1.1.2 CPU 竞争 原因:Redis 是单线程的,…...
目标检测:YOLO 模型详解
目录 一、YOLO(You Only Look Once)模型讲解 YOLOv1 YOLOv2 (YOLO9000) YOLOv3 YOLOv4 YOLOv5 YOLOv6 YOLOv7 YOLOv8 YOLOv9 YOLOv10 YOLOv11 YOLOv12 其他变体:PP-YOLO 二、YOLO 模型的 Backbone:Focus 结构 三、…...
HDFS存储原理与MapReduce计算模型
HDFS存储原理 1. 架构设计 主从架构:包含一个NameNode(主节点)和多个DataNode(从节点)。 NameNode:管理元数据(文件目录结构、文件块映射、块位置信息),不存储实际数据…...

电机控制选 STM32 还是 DSP?技术选型背后的现实博弈
现在搞电机控制,圈里人都门儿清 —— 主流方案早就被 STM32 这些 Cortex-M 单片机给拿捏了。可要是撞上系统里的老甲方,技术认知还停留在诺基亚砸核桃的年代,非揪着 DSP 不放,咱也只能赔笑脸:“您老说的对,…...

.NET 开源工业视觉系统 OpenIVS 快速搭建自动化检测平台
前言 随着工业4.0和智能制造的发展,工业视觉在质检、定位、识别等场景中发挥着越来越重要的作用。然而,开发一个完整的工业视觉系统往往需要集成相机控制、图像采集、图像处理、AI推理、PLC通信等多个模块,这对开发人员提出了较高的技术要求…...
从0到1掌握Kotlin高阶函数:开启Android开发新境界!
简介 在当今的Android开发领域,Kotlin已成为开发者们的首选编程语言。其高阶函数特性更是为代码的编写带来了极大的灵活性和简洁性。本文将深入探讨Kotlin中的高阶函数,从基础概念到实际应用,结合详细的代码示例和mermaid图表,为你呈现一个全面且深入的学习指南。无论你是…...
【OSS】 前端如何直接上传到OSS 上返回https链接,如果做到OSS图片资源加密访问
使用阿里云OSS(对象存储服务)进行前端直接上传并返回HTTPS链接,同时实现图片资源的加密访问,可以通过以下步骤实现: 前端直接上传到OSS并返回HTTPS链接 设置OSS Bucket: 确保你的OSS Bucket已创建…...

AI智能分析网关V4室内消防逃生通道占用检测算法打造住宅/商业/工业园区等场景应用方案
一、方案背景 火灾严重威胁生命财产安全,消防逃生通道畅通是人员疏散的关键。但现实中通道被占用、堵塞现象频发,传统人工巡查监管效率低、不及时。AI智能分析网关V4结合消防逃生通道占用算法,以强大的图像识别和数据分析能力,…...
商城前端监控体系搭建:基于 Sentry + Lighthouse + ELK 的全链路监控实践
在电商行业,用户体验直接关乎转化率和用户留存。一个页面加载延迟1秒可能导致7%的订单流失,一次未捕获的前端错误可能引发用户信任危机。如何构建一套高效的前端监控体系,实现错误实时追踪、性能深度优化与数据可视化分析?本文将揭…...
Kotlin 中的数据类型有隐式转换吗?为什么?
在 Kotlin 中,基本数据类型没有隐式转换。主要出于安全性和明确性的考虑。 1 Kotlin 的显式类型转换规则 Kotlin 要求开发者显式调用转换函数进行类型转换, 例如: val a: Int 10 val b: Long a.toLong() // 必须显式调用 toLong() // 错…...
基于 HTTP 的邮件认证深入解读 ngx_mail_auth_http_module
一、模块启用与示例配置 mail {server {listen 143; # IMAPprotocol imap;auth_http http://auth.local/auth;# 可选:传递客户端证书给认证服务auth_http_pass_client_cert on;auth_http_timeout 5s;auth_http_header X-Auth-Key "shared_se…...

关于无法下载Qt离线安装包的说明
不知道出于什么原因考虑,Qt官方目前不提供离线的安装包下载,意味着网上各种文章提供的各种下载地址都失效了,会提示Download from your IP address is not allowed,当然目前可以在线安装,但是据说只提供了从5.15开始的…...

Java开发经验——阿里巴巴编码规范实践解析4
摘要 本文主要介绍了阿里巴巴编码规范中关于日志处理的相关实践解析。强调了使用日志框架(如 SLF4J、JCL)而非直接使用日志系统(如 Log4j、Logback)的 API 的重要性,包括解耦日志实现、统一日志调用方式等好处。同时&…...