当我使用className时,我无法获取当前值,正确的值是“com.github.shadowsocks.Shadowsocks”。我的代码如下。
List<ApplicationInfo> apps;
apps = getPackageManager().getInstalledApplications(GET_SIGNATURES);
for (int i = 0; i < apps.size(); i++) {
if (apps.get(i).packageName.equals("com.github.shadowsocks")) {
tvShow.append("\n" + apps.get(i).backupAgentName);
tvShow.append("\n" + apps.get(i).className);
tvShow.append("\n" + apps.get(i).dataDir);
tvShow.append("\n" + apps.get(i).deviceProtectedDataDir);
tvShow.append("\n" + apps.get(i).manageSpaceActivityName);
tvShow.append("\n" + apps.get(i).nativeLibraryDir);
tvShow.append("\n" + apps.get(i).permission);
tvShow.append("\n" + apps.get(i).processName);
tvShow.append("\n" + apps.get(i).publicSourceDir);
tvShow.append("\n" + apps.get(i).sourceDir);
tvShow.append("\n" + apps.get(i).taskAffinity);
tvShow.append("\n" + apps.get(i).toString());
tvShow.append("\n" + apps.get(i).name);
tvShow.append("\n" + apps.get(i).packageName);
break;
}
}
答案 0 :(得分:0)
只需使用this.getClass().getCanonicalName()
答案 1 :(得分:0)
来自评论我觉得你想要APK的包名。下面的代码片段将返回apk的包名称:
context.getApplicationInfo().packageName
OR
context.getPackageName()