如何检测哪些Android应用使用其权限发送短信?

时间:2013-09-03 17:03:54

标签: android sms phone-number android-permissions

某些Android应用使用其权限向手机号码发送短信以从用户处提取资金。

如何检测哪些Android应用使用其权限发送短信?

1 个答案:

答案 0 :(得分:0)

这可能会有所帮助

final PackageManager pm = getPackageManager();
final List<ApplicationInfo> Apps = pm.getInstalledApplications(PackageManager.GET_META_DATA);

for ( ApplicationInfo app : Apps ) {
    // Info we can fetch app.packageName,app.uid, app.sourceDir

    // for Permissions:
    StringBuffer permissions = new StringBuffer();

    try {
        PackageInfo packageInfo = pm.getPackageInfo(app.packageName, PackageManager.GET_PERMISSIONS);

        String[] requestedPermissions = packageInfo.requestedPermissions;
        if ( requestedPermissions != null ) {
            for (int i = 0; i < requestedPermissions.length; i++) {
                permissions.append(requestedPermissions[i] + "\n");
            }

            // fetch  permissions
        }
    }
    catch ( PackageManager.NameNotFoundException e ) {
        e.printStackTrace();
    }
}