3

Given the list of installed packages on an Android device, is there a way to sort the applications into categories without using a self-compiled hard-coded list of apps in categories?

For example, if the installed apps were Phone, Angry Birds & Messages, Phone & Messages might be in Communications and Angry Birds in Games.

I've seen How to get Category for each App on device on Android? yet hoped there may be a method that has come along since.

4

3 回答 3

6

不,因为应用程序没有类别。应用不需要通过google play安装,其他商店的分类不一样。它可能从来没有从商店安装过——我一直在旁加载我自己或朋友编写的应用程序。这个概念不存在。

更不用说 Google Play 类别非常糟糕——事情经常不属于其中一个,描述模糊,而且它们太宽泛——它们至少需要 2 或 3 个级别的子类别才能使它们中途可用.

于 2013-07-21T19:20:31.913 回答
0

自上一个问题以来,API 没有任何变化。

充其量,您可以检索每个包名称并抓取 Google Play 页面。但是,如果应用程序不在 Google Play 上,这将失败。

于 2013-07-21T19:20:46.983 回答
0

我也面临同样的问题。上述查询的解决方案如下所述。

首先,下载Jsoup库或下载jar文件。

或将此添加到您的 build.gradle(Module: app) 实施 'org.jsoup:jsoup:1.11.3'

private class FetchCategoryTask extends AsyncTask {
private final String TAG = FetchCategoryTask.class.getSimpleName();
private PackageManager pm;

@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());
     }
  }
} 

作为回报,您将获得应用程序公司名称和应用程序类别

于 2018-12-21T05:02:43.193 回答