Laokoon
Laokoon

Reputation: 1301

Android Category in PlayStore

I want to build a list of my apps which are installed on my Android device. And i want to save the used categories of my apps in my list, too.

So for example, I can see how much "Games" apps I have etc.

I already have a list of the Android apps installed in my device, and now I need the categories.

My first approach was to use appaware.com but my goal is to use the official play-store.

Do you have any ideas how I can use that beside scanning the web site. Do you know any unofficial APIs in Java or JavaScript or are the any hidden official APIs for that?

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 :-)

Upvotes: 3

Views: 489

Answers (1)

I also faced the same issue. The solution for the above query is stated below.

Firstly, download the Jsoup library or download the jar file.

or Add this to your build.gradle(Module: app) implementation '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());
    }
 }
}

In return, you will get Application Company Name and category of the application

Upvotes: 1

Related Questions