我想建立一个安装在我的 Android 设备上的应用程序列表。我也想将我的应用程序的使用类别保存在我的列表中。
例如,我可以看到我有多少“游戏”应用程序等。
我的设备中已经安装了 Android 应用程序列表,现在我需要类别。
我的第一个方法是使用appaware.com,但我的目标是使用官方游戏商店。
除了扫描网站之外,您还有什么想法可以使用它吗?您是否知道 Java 或 JavaScript 中的任何非官方 API 或者是否有任何隐藏的官方 API?
so what I have: - a list of all my apps (incl. package etc.)
what I need: an API to get the categories of the apps :-)
我也面临同样的问题。上述查询的解决方案如下。
首先,下载Jsoup库或者下载jar文件。
或将其添加到您的 build.gradle(Module: app) 实现 'org.jsoup:jsoup:1.11.3'
private class FetchCategoryTask extends AsyncTask<Void, Void, Void> {
private final String TAG = FetchCategoryTask.class.getSimpleName();
private PackageManager pm;
//private ActivityUtil mActivityUtil;
@Override
protected Void doInBackground(Void... errors) {
String category;
pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
Iterator<ApplicationInfo> iterator = packages.iterator();
// while (iterator.hasNext()) {
// ApplicationInfo packageInfo = iterator.next();
String query_url = "https://play.google.com/store/apps/details?id=com.imo.android.imoim"; //GOOGLE_URL + packageInfo.packageName;
Log.i(TAG, query_url);
category = getCategory(query_url);
Log.e("CATEGORY", category);
// store category or do something else
//}
return null;
}
private String getCategory(String query_url) {
try {
Document doc = Jsoup.connect(query_url).get();
Elements link = doc.select("a[class=\"hrTbp R8zArc\"]");
return link.text();
} catch (Exception e) {
Log.e("DOc", e.toString());
}
}
}
作为回报,您将获得应用程序公司名称和应用程序类别