How to get Category for each App on device on Android?

前端 未结 7 1933
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 04:25

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

7条回答
  •  眼角桃花
    2020-12-03 04:36

    Probably a bit late, but the problem is still here. The OP has the advantage because of sending those results to the API (here I assume that the API is managed by the OP or his API colleagues at least).

    So, for anyone with the similar problem I'd suggest following:

    1. Collect all the package names you're interested in from device.
    2. Send that data to the your API
    3. API should extract package names and try to read results from its cache / db...
    4. For those packages that do not exist in cache / db make "market API" call and extract category - save it to the db / cache for reuse in this iteration.
    5. When all requests (to cache / db and market API) are completed do whatever you like with the results.

    Things to consider:

    When multiple users try to query your API for a same package name and you don't have a category for that package in your cache / db... Do 1 request to "market API" for packagex and update packagex in your cache / db to "waiting for results" state - next request should either get a "waiting for results" or a result that "market API" returned.

    One should also consider a fallback for possible "market API" fails (market API not working, not a google play app, or something similar). This decision is basically tied to your domain and the business trend that you're trying to catch will force a decision about this for you. If you're really into getting this category stuff sorted out you could pipeline this fallback to human decision and update your API db / cache for packagex accordingly.

    put up a nice API that would handle these and similar scenarios gracefully then one could probably even commercialize it up to a certain extent and "market API endpoint" - AKA play store package details page. That page would lose a big part of it's fake users :)

提交回复
热议问题