2.2 安卓14以上,无法获取mac地址,修改成获取唯一id作为mac地址
This commit is contained in:
@ -11,7 +11,7 @@ android {
|
|||||||
minSdk 28
|
minSdk 28
|
||||||
targetSdk 28
|
targetSdk 28
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "2.1"
|
versionName "2.2"
|
||||||
|
|
||||||
// 1.0 IDATA广播模式处理
|
// 1.0 IDATA广播模式处理
|
||||||
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
||||||
@ -34,6 +34,7 @@ android {
|
|||||||
// 1.18 瑞兴平板,读取扫描结果,使用同步加锁模式
|
// 1.18 瑞兴平板,读取扫描结果,使用同步加锁模式
|
||||||
// 1.19 index页面接入初始化数据
|
// 1.19 index页面接入初始化数据
|
||||||
// 2.1 注册PDA的信息存储到文件内部,采取mac+固定加密串的MD5加密校验
|
// 2.1 注册PDA的信息存储到文件内部,采取mac+固定加密串的MD5加密校验
|
||||||
|
// 2.2 安卓14以上,无法获取mac地址,修改成获取唯一id作为mac地址
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters 'armeabi-v7a'
|
abiFilters 'armeabi-v7a'
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
package chaoran.business.utils;
|
package chaoran.business.utils;
|
||||||
|
|
||||||
|
import static androidx.core.content.ContextCompat.getSystemService;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -62,6 +67,14 @@ public class LocalAddressUtil {
|
|||||||
@SuppressLint("JavascriptInterface")
|
@SuppressLint("JavascriptInterface")
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public String getMacAddress(){//可以兼容安卓7以下
|
public String getMacAddress(){//可以兼容安卓7以下
|
||||||
|
if (Build.VERSION.SDK_INT >= 34) { // Android 14 is code-named Tiramisu
|
||||||
|
try {
|
||||||
|
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "02:00:00:00:00:02";
|
||||||
|
}
|
||||||
|
}
|
||||||
String macAddress = null;
|
String macAddress = null;
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
NetworkInterface networkInterface = null;
|
NetworkInterface networkInterface = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user