如何获取 android app uids
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何获取 android app uids相关的知识,希望对你有一定的参考价值。
参考技术A 系统刚启动的时候,会对每个app分配一个uid,最简单的获取方式就是通过adb ,不过限于eng或userdebug版
adb pull data/system/packages.list d:\
当然最合理的方式是通过PackageManager
public List getUids()
List<Integer> uidList = new ArrayList<Integer>();
pm = getPackageManager();
List<PackageInfo> packinfos = pm
.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES
| PackageManager.GET_PERMISSIONS);
for (PackageInfo info : packinfos)
String[] premissions = info.requestedPermissions;
if (premissions != null && premissions.length > 0)
for (String premission : premissions)
if ("android.permission.INTERNET".equals(premission))
// System.out.println(info.packageName+"访问网络");
int uid = info.applicationInfo.uid;
Log.i("test", "uid = " + uid);
// String name = pm.getNameForUid(uid);
// // textName.setText(name);
// Log.i("test", "name = "+name);
uidList.add(uid);
return uidList;
本回答被提问者采纳
如何获取IMEI编号|离子| Android
我需要从Android设备获取IMEI,我正在使用IONIC应用程序。
我正在使用此插件-ionic cordova plugin add cordova-plugin-uid
参考链接-https://ionicframework.com/docs/native/uid/
这是我的代码段-
async getIMEI() {
const {hasPermission} = await this.androidPermissions.checkPermission(
this.androidPermissions.PERMISSION.READ_PHONE_STATE
);
console.log("hasPermission : " + hasPermission);
if (!hasPermission) {
const result = await this.androidPermissions.requestPermission(
this.androidPermissions.PERMISSION.READ_PHONE_STATE
);
if (!result.hasPermission) {
throw new Error('Permissions required');
}
// ok, a user gave us permission, we can get him identifiers after restart app
return 0 ;
}
return this.uid.IMEI;
}
我正在构造函数中调用getIMEI()-
constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController,
public apiProvider: ApiProvider, public storage: Storage, public platform: Platform, public fcm: FCM,
public uid: Uid, public androidPermissions: AndroidPermissions) {
platform.ready().then(() => {
if (this.platform.is('android')) {
console.log("running on Android device!");
this.deviceType = 'ANDROID';
this.getIMEI();
}
if (this.platform.is('ios')) {
console.log("running on iOS device!");
this.deviceType = 'IPHONE';
}
});
}
我总是将IMEI号码作为null值。
答案
您可以关注文档:https://ionicframework.com/docs/native/uid
首先将插件添加到您的应用中:
ionic cordova plugin add cordova-plugin-uid
npm install @ionic-native/uid
在ts文件中,您想获取IMEI:
import { Uid } from '@ionic-native/uid/ngx';
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
constructor(private uid: Uid, private androidPermissions: AndroidPermissions) { }
async getImei() {
const { hasPermission } = await this.androidPermissions.checkPermission(
this.androidPermissions.PERMISSION.READ_PHONE_STATE
);
if (!hasPermission) {
const result = await this.androidPermissions.requestPermission(
this.androidPermissions.PERMISSION.READ_PHONE_STATE
);
if (!result.hasPermission) {
throw new Error('Permissions required');
}
// ok, a user gave us permission, we can get him identifiers after restart app
return;
}
return this.uid.IMEI
}
以上是关于如何获取 android app uids的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Android 上的 ASE 中使用 Python 获取设备特定的 UID?
如何使用Nexus 5获取Mifare Ultralight 16位UID读数