Get a list of every launcher in Android

前端 未结 3 1072
不知归路
不知归路 2020-12-15 12:19

In my application I want to show a list of every available launcher (for homescreen) on that specific Android phone. Is it possible to get some kind of information from Andr

3条回答
  •  自闭症患者
    2020-12-15 12:27

    You can query the list of ResolverInfo that match with a specific Intent. The next snippet of code print all installed launchers.

    PackageManager pm = getPackageManager();
    Intent i = new Intent(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_HOME);
    List lst = pm.queryIntentActivities(i, 0);
    for (ResolveInfo resolveInfo : lst) {
        Log.d("Test", "New Launcher Found: " + resolveInfo.activityInfo.packageName);
    }
    

提交回复
热议问题