<small id='aKV0B'></small><noframes id='aKV0B'>

      1. <tfoot id='aKV0B'></tfoot>
        <legend id='aKV0B'><style id='aKV0B'><dir id='aKV0B'><q id='aKV0B'></q></dir></style></legend>
          <bdo id='aKV0B'></bdo><ul id='aKV0B'></ul>

      2. <i id='aKV0B'><tr id='aKV0B'><dt id='aKV0B'><q id='aKV0B'><span id='aKV0B'><b id='aKV0B'><form id='aKV0B'><ins id='aKV0B'></ins><ul id='aKV0B'></ul><sub id='aKV0B'></sub></form><legend id='aKV0B'></legend><bdo id='aKV0B'><pre id='aKV0B'><center id='aKV0B'></center></pre></bdo></b><th id='aKV0B'></th></span></q></dt></tr></i><div id='aKV0B'><tfoot id='aKV0B'></tfoot><dl id='aKV0B'><fieldset id='aKV0B'></fieldset></dl></div>

        如何在 Android 设备上获取每个应用程序的类别?

        How to get Category for each App on device on Android?(如何在 Android 设备上获取每个应用程序的类别?)
        <tfoot id='P51Vh'></tfoot>
              <bdo id='P51Vh'></bdo><ul id='P51Vh'></ul>
              <i id='P51Vh'><tr id='P51Vh'><dt id='P51Vh'><q id='P51Vh'><span id='P51Vh'><b id='P51Vh'><form id='P51Vh'><ins id='P51Vh'></ins><ul id='P51Vh'></ul><sub id='P51Vh'></sub></form><legend id='P51Vh'></legend><bdo id='P51Vh'><pre id='P51Vh'><center id='P51Vh'></center></pre></bdo></b><th id='P51Vh'></th></span></q></dt></tr></i><div id='P51Vh'><tfoot id='P51Vh'></tfoot><dl id='P51Vh'><fieldset id='P51Vh'></fieldset></dl></div>
                <tbody id='P51Vh'></tbody>
                • <small id='P51Vh'></small><noframes id='P51Vh'>

                  <legend id='P51Vh'><style id='P51Vh'><dir id='P51Vh'><q id='P51Vh'></q></dir></style></legend>
                  本文介绍了如何在 Android 设备上获取每个应用程序的类别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 Android 应用程序,它会扫描设备上安装的所有应用程序,然后将其报告给服务器(它是 MDM 代理).有关如何获取应用程序类别的任何建议?每个人都有不同的类别列表,但基本上是游戏、娱乐、工具/实用程序等.

                  I've got an Android app which scans for all Apps installed on the device and then reports this to a server (it's an MDM agent). Any suggestions on how to get the Category of the App? Everyone has a different list of Categories, but basically something like Game, Entertainment, Tools/Utilities, etc.

                  据我所知,与设备本身存储的类别无关.我正在考虑使用 android market API 在市场中搜索应用程序并使用搜索返回的 Category 值.不确定这将如何成功找到匹配项.有关如何最好地做到这一点的任何建议?

                  From what I can tell there is nothing related to Category stored on the device itself. I was thinking of using the android market API to search for the application in the market and use the Category value returned by the search. Not sure how successful this will be finding a match. Any suggestions on how best to do this?

                  对不同的方法有什么建议吗?

                  Any suggestions on a different approach?

                  提前致谢.迈克

                  推荐答案

                  如果你为每个应用获取了它的包名,你可以直接询问 play store 一个应用属于哪个类别,用这个库解析 html 响应页面:

                  if you get for each application its package name, you could ask directly to play store which category an app belongs, parsing html response page with this library:

                  org.jsoup.jsoup1.8.3

                  这里有一个片段可以解决你的问题:

                  Here's a snippet to solve your problem:

                  public class MainActivity extends AppCompatActivity {
                  
                  public final static String GOOGLE_URL = "https://play.google.com/store/apps/details?id=";
                  public static final String ERROR = "error";
                  
                  ...
                  
                  
                     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 = GOOGLE_URL + packageInfo.packageName;
                                 Log.i(TAG, query_url);
                                 category = getCategory(query_url);
                                 // store category or do something else
                             }
                             return null;
                          }
                  
                  
                          private String getCategory(String query_url) {
                             boolean network = mActivityUtil.isNetworkAvailable();
                             if (!network) {
                                 //manage connectivity lost
                                 return ERROR;
                             } else {
                                 try {
                                     Document doc = Jsoup.connect(query_url).get();
                                     Element link = doc.select("span[itemprop=genre]").first();
                                     return link.text();
                                 } catch (Exception e) {
                                     return ERROR;
                                 }
                             }
                          }
                      }  
                  }
                  

                  您可以在 AsyncTask 或服务中进行这些查询.希望对您有所帮助.

                  You could make these queries in an AsyncTask, or in a service. Hope that you find it helpful.

                  这篇关于如何在 Android 设备上获取每个应用程序的类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)
                  How can i use MYSQL database connection in iphone application useing cocos2d?(如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?)
                  Smoothly drag a Sprite in cocos2d - iPhone(在 cocos2d 中平滑拖动一个 Sprite - iPhone)
                  CCScrollView scroll and touch events never firing(CCScrollView 滚动和触摸事件永远不会触发)
                  removing jagged edges of my ropes using antialiasing of OpenGLES(使用 OpenGLES 的抗锯齿去除绳索的锯齿状边缘)
                  cocos2d Moving between scene(cocos2d 在场景之间移动)
                  <tfoot id='QagTf'></tfoot>

                    1. <legend id='QagTf'><style id='QagTf'><dir id='QagTf'><q id='QagTf'></q></dir></style></legend>

                        <small id='QagTf'></small><noframes id='QagTf'>

                          <tbody id='QagTf'></tbody>
                        <i id='QagTf'><tr id='QagTf'><dt id='QagTf'><q id='QagTf'><span id='QagTf'><b id='QagTf'><form id='QagTf'><ins id='QagTf'></ins><ul id='QagTf'></ul><sub id='QagTf'></sub></form><legend id='QagTf'></legend><bdo id='QagTf'><pre id='QagTf'><center id='QagTf'></center></pre></bdo></b><th id='QagTf'></th></span></q></dt></tr></i><div id='QagTf'><tfoot id='QagTf'></tfoot><dl id='QagTf'><fieldset id='QagTf'></fieldset></dl></div>

                        • <bdo id='QagTf'></bdo><ul id='QagTf'></ul>